Jump to content

Lisp for drawing poliyline with 3 inputs and a close


V-SAM

Recommended Posts

HELP !!

I am looking for a quick way to key-in 3 dimensions and then have a rectangle polyline drawn and closed. It could automatically start drawing at 0,0,0

 

The three user entries would be A, B, C where A and C would be different and the program would close the object.

 

See attached for a better explanation.

 

I appreciate any input on this.. I am not very good at writing lisps but i have good visions :) THanks guys you are the best.

Document1.pdf

Link to comment
Share on other sites

Why do you need a lisp routine to draw that shape? It could all be done at the command line very quickly.

 

Command: _pline

Specify start point:

Current line-width is 0.0000

Specify next point or [Arc/Halfwidth/Length/Undo/Width]: 10

 

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: 4

 

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: 14

 

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: c

Link to comment
Share on other sites

I know it is very simple... however I have an engineer who wants to just type in three dimensions and nothing else and have it done for him...

Link to comment
Share on other sites

I see. I think I'll stop now before I say something I'll regret.

 

I'm sure one of the lisp gurus here can solve this dilemma for your engineer in no time flat.

 

Good luck and happy coding.

Link to comment
Share on other sites

This one ?

 

(defun c:Test (/ i x p pt l)
 (setq i 0
       x '("First" "Second" "Third" "Fourth")
 )
 (while (and
          (not (eq (length l) 4))
          (if pt
            (setq p (getpoint (strcat "\n" (nth i x) " point :") pt))
            (setq p (getpoint (strcat "\n" (nth i x) " point :")))
          )
          (setq pt p)
        )
   (setq l (cons p l)
         i (1+ i)
   )
 )
 (if (eq (length l) 4)
   (command "_.pline"
            "_non"
            (car l)
            "_non"
            (cadr l)
            "_non"
            (caddr l)
            "_non"
            (nth 3 l)
            "c"
   )
 )
 (princ)
)

Link to comment
Share on other sites

Feeling generous...

 

(defun c:Test (/ a b c p1 p2)
 (if (and (progn (initget 6) (setq a (getdist "\nSpecify length of side A: ")))
          (progn (initget 6) (setq b (getdist "\nSpecify length of side B: ")))
          (progn (initget 6) (setq c (getdist "\nSpecify length of side C: ")))
          (setq p1 (getpoint "\nSpecify intersection of sides A and C: "))
     )
   (command "_.pline"
            "_non"
            (mapcar '+ p1 (list 0. a 0.))
            "_non"
            p1
            "_non"
            (setq p2 (mapcar '+ p1 (list c 0. 0.)))
            "_non"
            (mapcar '+ p2 (list 0. b 0.))
            "_close"
   )
 )
 (princ)
)

Edited by alanjt
Link to comment
Share on other sites

(defun c:Test (/ a b c)
 (initget 6)
 (if (and (setq a (getdist "\nSpecify length of side A: "))
          (progn (initget 6) (setq b (getdist "\nSpecify length of side B: ")))
          (progn (initget 6) (setq c (getdist "\nSpecify length of side C: ")))
     )
   (command "_.pline"
            "_non"
            (list 0. a 0.)
            "_non"
            '(0. 0. 0.)
            "_non"
            (list c 0. 0.)
            "_non"
            (list c b 0.)
            "_close"
   )
 )
 (princ)
)

Link to comment
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
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...