- UID
- 5
- 积分
- 2526
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
发表于 2007-9-11 20:39:57
|
显示全部楼层
使用ActiveX接口。偏移值一个给正,一个给负。

- ;; Arc, Circle, Ellipse, Line, LightweightPolyline, Polyline, Spline, XLine
- (vl-load-com)
- (defun C:offset2 (/ ent dist)
- (setq
- dist (getdist
- (strcat "双向偏移的距离:<" (rtos (getvar "OFFSETDIST")) ">")
- )
- )
- (if (null dist)
- (setq dist (getvar "offsetdist"))
- (setvar "offsetdist" dist)
- )
- (setq ent
- (i:entselF
- "\n选择要双向偏移的对象:"
- '((0
- .
- "ARC,ELLIPSE,CIRCLE,LINE,POLYLINE,LWPOLYLINE,XLINE,SPLINE"
- )
- )
- )
- )
- (princ ent)
- (if ent
- (progn
- (setq ent (car ent))
- (setq ent (vlax-ename->vla-object ent))
- (vla-offset ent dist)
- (vla-offset ent (- 0 dist))
- )
- )
- (princ)
- )
- (defun I:EntSelF
- (Msg ; selection prompt
- Filter ; filter list
- / EntN ; (entsel) list, or "Exit" string
- pbDist ; pickbox size in drawing units
- PtPick ; point of selection from (entsel)
- ssPick ; selection set
- ) ;_ closes variable declare
- (while (not EntN) ; while no selection (or no exit)
- (setq
- EntN (if Msg ; if selection prompt
- (entsel Msg) ; then (entsel) w/prompt
- (entsel) ; else plain (entsel)
- ) ;_ closes if
- ) ;_ closes setq
- (if (= (getvar "ErrNo") 52) ; if null response
- (setq EntN "Exit") ; then set flag to exit
- ) ;_ closes if
- ) ;_ closes while
- (cond
- ((/= EntN "Exit") ; if not exit
- (setq
- pbDist (abs ; return absolute number
- (/
- (*
- (/ ; get pixel ratio
- (getvar "PickBox")
- (cadr (getvar "ScreenSize"))
- )
- (getvar "ViewSize") ; apply to viewsize
- ) ;_ closes *
- (sin (* 0.25 pi)) ; at 45?
- ) ;_ closes /
- ) ;_ closes abs
- PtPick (cadr EntN) ; get point of pick
- ) ;_ closes setq
- (if (setq ssPick (ssget "_C" ; if entities in crossing
- (polar PtPick (* 1.25 pi) pbDist)
- (polar PtPick (* 0.25 pi) pbDist)
- Filter ; match filter, if any
- ) ;_ closes ssget
- ) ;_ closes setq
- (cons ; then return first entity as (entsel)
- (ssname ssPick 0)
- (list PtPick)
- ) ;_ closes cons
- ) ;_ closes if
- ) ;_ closes condition
- ) ;_ closes cond
- ) ;_ closes defun I:EntSelF
- (princ)
[/FONT] |
|