Jump to content

Recommended Posts

Posted (edited)

I'm a land surveyor. Years ago I worked at a company that had a script or lisp to draw a house. Basically you started a polyline and then drug the cursor the direction you wanted to go. Then you would put in the distance. Then you simply type the next distance and would draw that distance 90° to the right of the last line. Or if you put a - in front of the distance it would draw 90° to the left of the last line. Or you could add / or \ to draw 45° to the last line. You would continue until you are done. I would be willing to pay $$$$ if someone could write this for me. 

Edited by Ataim
Posted

Do you remember what the command was to run the LISP - you never know, someone might have a copy or a link to it

Posted

Many years ago "Civilcad" software had that function, draw a shape and click on boundaries you could do things like set a side and slide along that side with updating offset to other sides as one option. So understand what you want but no solution, sorry. Not sure if it ended up in current software "Magnet". Note in the image the offset line to the angled line., it will always be the closest corner and changes automatically depending on the shape.

image.png.87d2cd49744f3640b2e5ef05b8efc04c.png

 

Welcome to Cadtutor. Post a sample dwg with some examples of what your looking for, a before and after is best.

Posted

look into dynamic blocks

Posted (edited)

Try this as a first pass, see if I have the idea right:

 

Not quite as described and only draws lines as it is, rather than Polylines, but it being a Sunday and the CAD should be off it will do for a start, or if it inspires anyone tonight.

To consider later:

Fixing the loop - as it is just escape out of the LISP to end or join last point to start point.

Join the lines together as Polylines (See Lee Mac PLJoin?)

 

(defun c:testthis ( / Pta Ptb Pt1 Pt2 MyLine MyDistance MyAngle ed RefLine RefAngle )
  (defun LM:roundm ( n m ) ;; Lee Mac ;; Round to nearest m
    (* m (fix ((if (minusp n) - +) (/ n (float m)) 0.5)))
  )
  (command "line" pause pause "")   ; Draw first segment
  (setq RefLine (entlast))          ; Line entitity name
  (setq Pta (setq Pt1 (cdr (assoc 10 (entget RefLine)))) ) ; First line start point
  (setq Ptb (setq Pt2 (cdr (assoc 11 (entget RefLine)))) ) ; first line end point
  (setq RefAngle (angle Pt1 Pt2) ) ; First line absolute angle

  (setq endloop "No")              ; marker to keep loop going
  (while                           ; While loop
    (and
      (= endloop "No")             ; Marker still 'no'
      (= (command "line" Pt2 pause "") nil) ; and user draws a line
    ) ; end and
    (setq ed (entget (entlast)))   ; next segment entity name
    (setq Pt1 (cdr (assoc 10 ed))) ; next segment start point (also last one end point (Setq Pt1 Pt2) should also work
    (setq Pt2 (cdr (assoc 11 ed))) ; next segment end point
    (if (equal Pt2 Pta)            ; If next segment end point = first segment start point
      (progn
        (princ "Closed Polyline")
        (setq Endloop "Yes")      ; set end loop marker & end loop
      ) ; end progn
      (progn                      ; else
        (setq MyDistance (distance Pt1 Pt2)) ; Record next segment distance
        (setq MyAngle (LM:roundm (- (angle Pt1 Pt2) RefAngle) (/ pi 4) )) ; next segment angle relative to first segment, rounded to pi/4 (45 degrees)
                                                                          ; pi/4: 45 degree angles, pi/12 for 15 degrees
        (setq Pt2 (polar Pt1 (+ MyAngle RefAngle) MyDistance))            ; Calculate new PT from rounded angle
        (setq ed (subst (cons 11 Pt2) (assoc 11 ed) ed ))                 ; Modify the segment to perpendicular / 45 degree
        (entmod ed)                                                       ; update next segment
      ) ; end progn
    ) ; end if
  ) ; end loop
  (princ)
) ; end defun

 

Edited by Steven P

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...