(defun c:XOFF (/
os_sav Dis Obj Dat Typ side Flag Rad New Beg Last
)
(setq os_sav (getvar "OFFSETDIST")) ; save normal
offset distance fo later restoration
(if $#ox (= nil) (setq $#ox 1.0)) ; default
global od offset distance for this session
(setq Dis (getreal (strcat "\nOffset distance : ")))
(if Dis (setq $#ox Dis)) ; set global od dist
to user input if there is one
(setq Obj (nentsel "\nSelect object to offset: "))
(while Obj ; allow
multiple offsets
(setq
Dat (entget (car Obj))
Typ (strcase (cdr (assoc 0 Dat)))
Flag nil
)
(cond
((= Typ "LWPOLYLINE")(setq Flag 1 side (getpoint "\nSide to offset:
")));test LWPOLYLINE
((= Typ "LINE") (setq Flag 1 side (getpoint "\nSide to offset:
")));test LINE
((= Typ "CIRCLE")
(setq
Flag 0
side (getpoint "\nSide to offset: ")
Rad (cdr (assoc 40 Dat))
New (if (< (distance (cdr (assoc 10 Dat)) Side) Rad) (- Rad $#ox)
(+ Rad $#ox))
);setq
);test CIRCLE
((= Typ "ARC")
(setq
Flag 0
side (getpoint "\nSide to offset: ")
Rad (cdr (assoc 40 Dat))
New (if (< (distance (cdr (assoc 10 Dat)) Side) Rad) (- Rad $#ox)
(+ Rad $#ox))
);setq
);test ARC
(T (setq Flag -1));test default
);cond
(setq Beg (subst (cons '8 (getvar "CLAYER"))(assoc 8 Dat) Dat))
(command "UNDO" "BE")
(cond
((= Flag 1) (entmake Beg) (setq Last (entlast)) (command "OFFSET"
$#ox Last side "") (entdel Last))
((= Flag 0) (setq Beg (subst (cons '40 New)(assoc 40 Beg) Beg))
(entmake Beg))
((= Flag -1) (prompt "\nCannot offset that object."))
(T (alert "Error encountered"))
)
(setq Obj (nentsel "\nSelect object to offset: ")) ; input for
loop
(command "UNDO" "E")
);while
(setvar "OFFSETDIST" os_sav) ; restore
saved normal offset distance
(princ)
)
(c:XOFF)
;defun

Advertisements