Jump to content

3d Line Lisp Needed


Recommended Posts

Hello, I need a LISP routine that will allow me to draw a line with a “Z” coordinate. I would like to click on a spot in current x,y plain and then be prompted to enter a “Z” or ELEVATION for the start of the line and then click on the end of the line and be prompted again to enter the “Z” coordinate. The end of this line will be the beginning of the next line and then continue picking and entering “Z” coordinates to form a series of 3D lines each having the same “Z” coordinate at their intersections. Any help would be greatly appreciated, thank you!

Link to post
Share on other sites
Lee Mac

Just a quick one:

(defun c:lz (/ pt1 z1 pt2 z2)
 (while
   (and
     (setq pt1 (getpoint "\nSpecify First Point: "))
     (or (setq z1 (getdist "\nSpecify Z <0.0>: ")) (setq z1 0.0))
     (setq pt2 (getpoint pt1 "\nSpecify Next Point: "))
     (or (setq z2 (getdist "\nSpecify Z <0.0>: ")) (setq z2 0.0)))
   (command "_.line" "_non"
     (list (car pt1) (cadr pt1) z1) "_non"
     (list (car pt2) (cadr pt2) z2) ""))
 (princ))

Link to post
Share on other sites

Thank you David and Lee, both of these methods are much better than what I was doing.

Lee, can the .lsp be modified to continue the line, making a 3d multi line using the endpoint coordinates of the previous line to start the next line?

Link to post
Share on other sites
Lee Mac

Perhaps:

 

(defun c:lz  (/ pt1 z1 pt2 z2 pt3 z3)
 (if (and (setq pt1 (getpoint "\nSpecify First Point: "))
          (or (setq z1 (getdist "\nSpecify Z <0.0>: ")) (setq z1 0.0))
          (setq pt2 (getpoint (if pt2 pt2 pt1) "\nSpecify Next Point: "))
          (or (setq z2 (getdist "\nSpecify Z <0.0>: ")) (setq z2 0.0)))
   (progn
     (command "_.line"  "_non"
              (list (car pt1) (cadr pt1) z1) "_non"
              (list (car pt2) (cadr pt2) z2) "")
     (while (and (setq pt3 (getpoint pt2 "\nSpecify Next Point: "))
                 (or (setq z3 (getdist "\nSpecify Z <0.0>: ")) (setq z3 0.0)))
       (command "_.line" "_non"
                (list (car pt2) (cadr pt2) z2)
                (list (car pt3) (cadr pt3) z3) "")
       (setq z2 z3 pt2 pt3))))
 (princ))

Link to post
Share on other sites

Lee,

Thank you! I just loaded the file and it works perfectly. If there is something I can do for you let me know.

Tod Mohr

Link to post
Share on other sites

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
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...