Offset Both Sides, current layer

Offset Both Sides, current layer

whilisonmarques25
Explorer Explorer
2,984 Views
3 Replies
Message 1 of 4

Offset Both Sides, current layer

whilisonmarques25
Explorer
Explorer

Hey guys,

I found one lisp that helped me a lot, creating a offset to both side. But I can't choose if the layer will be the current or origin. Someone can help me?

 

 

Thanks.

The lisp that i'm using is:

 

 

 

defun c:dOff ( / *error* of undo doc ss )
(vl-load-com)

(defun *error* ( msg )
(and undo (vla-EndUndomark doc))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ)
)

(if (and (ssget '((0 . "ARC,CIRCLE,ELLIPSE,*LINE")))
(setq of (getdist "\nSpecify Offset Distance: ")))
(progn
(setq undo
(not
(vla-StartUndomark
(setq doc
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
)
)
)

(vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc))
(mapcar
(function
(lambda ( o )
(vl-catch-all-apply
(function vla-offset) (list obj o)
)
)
)
(list of (- of))
)
)
(vla-delete ss)

(setq undo (vla-EndUndoMark doc))
)
)
(princ)
)

 

0 Likes
Accepted solutions (1)
2,985 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

THIS is better found.

Message 3 of 4

Kent1Cooper
Consultant
Consultant

Unfortunately, (vla-offset) doesn't honor the to-which-Layer option in the Offset command.  But if (command "_.offset" ...) can be used instead, that does  honor the current setting of that option.  Re-writing the code to do it that way would add the complication of needing to find locations guaranteed to be on both sides of each object [not  needing to do that is the big advantage of using (vla-offset) for this].  That would not be difficult for Lines/Arcs/Circles/Ellipses/Xlines, but a foolproof determination can be near-impossible for things with potentially very irregular shapes, such as Polylines and Splines.  But if you do it in situations with enough simplicity and predictability, something could probably be done.

Kent Cooper, AIA
0 Likes
Message 4 of 4

john.uhden
Mentor
Mentor

It doesn't seem like such a big deal to me.

He has a catch-all in there for if a vla-offset fails, and the method returns an array of the objects created so their layer can be changed to clayer.

Perhaps that's what Lee Mac's DoubleOffset does.  I haven't looked at it.

John F. Uhden

0 Likes