searchinf for a lisp routine

searchinf for a lisp routine

Anonymous
Not applicable
1,118 Views
10 Replies
Message 1 of 11

searchinf for a lisp routine

Anonymous
Not applicable

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. 

 

then I have to trim them all against each other....

but that is another problem...

 

the reason I am looking for this is to speed up my production.

coming back from a while off and acad 2017 has a steep learning curve.

0 Likes
Accepted solutions (1)
1,119 Views
10 Replies
Replies (10)
Message 2 of 11

Ranjit_Singh
Advisor
Advisor

Try the following. It is hard coded for your layers as you mentioned row, lot line and property line. If you need to, then change layer names in the lisp. I have commented the line where you can feed this information. In any case update the default offset distances from 5, 6 and 7 to whatever you need. In case of lot line the lisp will allow to pick points on both sides of the lot line.

 

(defun c:somefunc  (/ ss1 i ent entdata laofflst)
    (setq laofflst (list '("row" . 5) '("lot line" . 6) '("property line" . 7)); offsets row, lot line and property line through 5, 6 and 7' respectively; change as needed
          i 0)
    (while (setq ss1
                    (ssget
                        (list (cons 0 "line,lwpolyline,arc,circle")
                        (cons 8
                              (vl-string-right-trim ","
                                                    (apply 'strcat (mapcar '(lambda (x) (strcat (car x) ",")) laofflst)))))))
        (repeat (sslength ss1)
            (cond ((= (cdr (assoc 8 (setq entdata (entget (setq ent (ssname ss1 i)))))) (caar laofflst))
                   (prompt "\nSelect point on side to offset: ")
                   (command "._offset" (cdr (assoc (caar laofflst) laofflst)) ent pause ""))
                  ((= (cdr (assoc 8 (setq entdata (entget (setq ent (ssname ss1 i)))))) (caaddr laofflst))
                   (prompt "\nSelect point on side to offset: ")
                   (command "._offset" (cdr (assoc (caaddr laofflst) laofflst)) ent pause ""))
                  (T
                   (prompt "\nSelect point on side to offset: ")
                   (command "._offset" (cdr (assoc (caadr laofflst) laofflst)) ent "_m" pause pause "" "")))
            (setq i (1+ i))))
    (princ))

 

0 Likes
Message 3 of 11

Anonymous
Not applicable

thanks for the quick response.  I just now got on to see it.

 

will try is out.

 

Thanks

 

 

0 Likes
Message 4 of 11

Kent1Cooper
Consultant
Consultant

@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
0 Likes
Message 5 of 11

Anonymous
Not applicable

what would I edit to change it to the correct layer names?...

 

C-PROP-TRCT-N = property

C-PROP-RWAY-N=row

C-PROP-LOTS-N-lots

0 Likes
Message 6 of 11

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

what would I edit to change it to the correct layer names?...

....


Editing it in Notepad, Ctrl+H gets you the find-and-replace function.  It should be pretty obvious what to do from there.  Or you can just replace them manually -- each Layer name occurs only twice.

Kent Cooper, AIA
0 Likes
Message 7 of 11

Anonymous
Not applicable

I have tried several different modifications....

 

this one works except for the lot lines, which are... C-PROP-LOTS-N

 

(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 Tract 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))))) "C-PROP-RWAY-N,C-PROP-LOTS-N,C-PROP-TRCT-N")
      (wcmatch (cdr (assoc 0 (entget (car esel)))) "LINE,ARC,*POLYLINE")
    ); and
    (if (= lay "C-PROP-LOTS-N")
      (progn ; then -- both sides
        (vla-offset (setq obj (vlax-ename->vla-object (car esel))) C-PROP-LOTS-N)
        (vla-offset obj (- lot))
      ); progn
      (command "_.offset" ; else
        (cdr (assoc lay (list (cons "C-PROP-RWAY-N" row) (cons "C-PROP-TRCT-N" prop))))
        (cadr esel) pause "" ; User specifies side
      ); command
    ); if
  ); while
); defun
(vl-load-com)

 

0 Likes
Message 8 of 11

Anonymous
Not applicable

oops, I think I found it , I think I changed one to many lots  

0 Likes
Message 9 of 11

Anonymous
Not applicable

nope....I thought this was it  

 

 (if (= lay "C-PROP-LOTS-N")

0 Likes
Message 10 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

I have tried several different modifications....

 

this one works except for the lot lines, which are... C-PROP-LOTS-N

 

....
  (setq
....
    lot (getdist "\nSetback (both sides) from intermediate LOT lines: ")
....
        (vla-offset (setq obj (vlax-ename->vla-object (car esel))) C-PROP-LOTS-N)
....


Maybe I shouldn't have used the same spelling for variable names as for Layers [other than their case].  If you use Ctrl+H in Notepad, and didn't check the Match Case button, then you appear to have changed some variable names as if they were the Layer names.  Try changing it back in that line:

 

        (vla-offset (setq obj (vlax-ename->vla-object (car esel))) lot)

 

[It may not be the only one -- I didn't dig too deeply.]

Kent Cooper, AIA
0 Likes
Message 11 of 11

Anonymous
Not applicable

well looks like I fix what I messed up and its working....

 

I will work out how to put it on a current layer

 

thank you very much!

0 Likes