@Anonymous wrote:
looking for a way to offset different distances based on the 1 of 3 layers I pick.
such as, row, lot line(2 sides), property line
I am generating setbacks.
....
Since the setback distances from all those kinds of edges will vary with different Zoning classifications, it would not be viable to build specific distances into a command definition, unless you want to make different commands for each different Zoning category and jurisdiction. So the following code asks the User for what the setback is to be from each kind of edge. If it works for you, it could easily be expanded to remember what you gave it, and offer it as a default value for each edge type the next time you use the command, so you don't have to enter the distances again each time, but first see whether it works otherwise.
It uses Layer names "ROW" and "PROPERTY" and "LOT", so replace those [in all locations] with your actual Layer names. It's case-sensitive, but could be made to not be case-sensitive if needed. It automatically Offsets to both sides for things on the "LOT" Layer, and lets the Offset command's own prompt ask the User for which side for things on the other Layers. The User can select as many such edges on any of those Layers as they want in one running of the command, but one at a time, since that seems a more logical way to allow the which-side pick for each one that needs it, rather than selecting multiple objects all at once.
It allows selections of only Lines, Arcs, and Polylines, assuming you won't have other entity types defining such edges -- I've never seen any involving other Offsettable entity types [Circles, Ellipses, Splines], but they could be added if needed. Of course, if any are Polylines, they could involve multiple segments, so it's up to you to ensure that every segment in the same Polyline belongs in the same category and needs to be Offset by the same distance [no Polyline boundaries all the way around a lot in one piece, for instance].
It could also be made to ask again if the User misses in picking, or picks some invalid kind of thing [currently either situation ends the command].
(defun C:SBL ; = Setback By Layer
(/ row prop lot esel lay obj)
(setq
row (getdist "\nSetback from Right-of-Way lines: ")
prop (getdist "\nSetback from PROPERTY lines: ")
lot (getdist "\nSetback (both sides) from intermediate LOT lines: ")
); setq
(while
(and
(setq esel (entsel "\nSelect edge to draw Setback(s): "))
(wcmatch (setq lay (cdr (assoc 8 (entget (car esel))))) "ROW,LOT,PROPERTY")
(wcmatch (cdr (assoc 0 (entget (car esel)))) "LINE,ARC,*POLYLINE")
); and
(if (= lay "LOT")
(progn ; then -- both sides
(vla-offset (setq obj (vlax-ename->vla-object (car esel))) lot)
(vla-offset obj (- lot))
); progn
(command "_.offset" ; else
(cdr (assoc lay (list (cons "ROW" row) (cons "PROPERTY" prop))))
(cadr esel) pause "" ; User specifies side
); command
); if
); while
); defun
(vl-load-com)
Kent Cooper, AIA