Lisp program doesn't work well

Lisp program doesn't work well

ramoneramone
Enthusiast Enthusiast
519 Views
4 Replies
Message 1 of 5

Lisp program doesn't work well

ramoneramone
Enthusiast
Enthusiast

Hi dear

 

I'm writing a Lisp program but doesn't work well.

I want to draw a line. 

 

Does anyone help me?

 

(progn
(setq orign(getpoint "select base point"))
(setq PtX (car orign) PtY (cadr orign))

(setq dh (getint "H1?"))
(setq ch (getint "H2?"))
(setq fh (getint "H3?"))


#Input H1
(setq PtY_dh (+ dh PtY))
(setq Pt_dh(list PtX PtY_dh))
#H1 drawing
(command "line" orign "@2000,0" "")
(command "line" Pt_dh "@2000,0" "")


#Input H2
(setq PtY_ch (+ ch fh PtY))
(setq Pt_ch(list PtX PtY_ch))
#H2 drawing
(command "line" PT_ch "@2000,0" "")



#Input H3
(setq PtY_fl (+ fh PtY))
(setq Pt_fl(list PtX PtY_fl))
#H3 drawing
(command "line" Pt_fl "@2000,0" "")

)

0 Likes
Accepted solutions (1)
520 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

@ramoneramone wrote:

... but doesn't work well.  I want to draw a line. ....


"Doesn't work well?"  What does that mean?  Doesn't work at all?  Works partially?  How many of the four Lines you appear to really want to draw does it draw?  What happens, or doesn't happen?  Are there any messages?  Etc., etc.

Kent Cooper, AIA
Message 3 of 5

annoisscary
Advocate
Advocate
Accepted solution

I'm with Kent on needing a better description to get to the bottom of what exactly is going on, however I took a crack at your code since I don't have anything better to do. Assuming its a part of a larger code since it starts with  a (progn, but since you didn't really give any other context I just wrote it as if it was a standalone 1 off. Used a custom function for making a line with 1 point and a length instead of "command".

 

(defun C:3LN ( / orign ptx dh ch fh pty_dh pt_dh pty_ch pt_ch yty_fl pt_fl pt_fl)
  (defun 3ln (p1 len)
  
	;Entmake Line Function, Takes Start point and length. +/- values accepted
	;if you want left do it like this, (3ln PT (- distance))
	(setq p2 (mapcar '+ p1 (list len 0 0)))
	(entmakex (list (cons 0 "LINE")(cons 10 p1)(cons 11 p2))))
  
	(setq orign(getpoint "select base point"))
	(setq ptx (car orign) pty (cadr orign))

	(setq dh (getint "H1?"))
	(setq ch (getint "H2?"))
	(setq fh (getint "H3?"))

	;#Input H1
	(setq pty_dh (+ dh ptY))
	(setq pt_dh(list ptx pty_dh))
	;#H1 drawing
	(3ln orign 2000)
	(3ln pt_dh 2000)

	;#Input H2
	(setq pty_ch (+ ch fh pty))
	(setq pt_ch(list ptx pty_ch))
	;#H2 drawing
	(3ln pt_ch 2000)

	;#Input H3
	(setq pty_fl (+ fh pty))
	(setq pt_fl(list ptx pty_fl))
	;#H3 drawing
	(3ln pt_fl 2000)

)

 

Message 4 of 5

ramoneramone
Enthusiast
Enthusiast

Sorry , I didn't explain enough.

 

The first time you run the program, it works fine.

However, the next time it is moved, it does not work.

 

(progn (setq orign(getpoint "select base point"))(setq PtX (car orign) PtY (cadr orign))(setq dh (getint "H1?"))(setq ch (getint "H2?"))(setq fh (getint "H3?"))(setq PtY_dh (+ dh PtY))(setq Pt_dh(list PtX PtY_dh))(command "line" orign "@2000,0" "")(command "line" Pt_dh "@2000,0" "")(setq PtY_ch (+ ch fh PtY))(setq Pt_ch(list PtX PtY_ch))(command "line" PT_ch "@2000,0" "")(setq PtY_fl (+ fh PtY))(setq Pt_fl(list PtX PtY_fl))(command "line" Pt_fl "@2000,0" ""))

0 Likes
Message 5 of 5

ramoneramone
Enthusiast
Enthusiast

(command "line" Pt_fl "@2000,0" "")

 

In this section, lines are drawn in orign coordinates.

0 Likes