REQ:- lisp to draw left and right line segment from point locate between them

REQ:- lisp to draw left and right line segment from point locate between them

abdulellah.alattab
Advocate Advocate
1,336 Views
16 Replies
Message 1 of 17

REQ:- lisp to draw left and right line segment from point locate between them

abdulellah.alattab
Advocate
Advocate

lisp senario attached in images lispsenario.jpgليسب رسم خط من جهتين.JPG

0 Likes
Accepted solutions (3)
1,337 Views
16 Replies
Replies (16)
Message 2 of 17

ВeekeeCZ
Consultant
Consultant
(defun c:Lines (/ pnt tmp sds ds1 ds2 fc1 fc2)
  
  (while (setq pnt (getpoint "\nSpecify a Core point <done>: "))
    
    (setq tmp (getpoint "\nPick a side: " pnt)
	  sds (if (> (- (cadr tmp) (cadr pnt)) 0)
		'("RIGHT" "LEFT")
		'("LEFT" "RIGHT" ))
	  ds1 (getdist (strcat "Specify " (car sds) " distance: "))
	  fc1 (getdist (strcat "Specify " (car sds) " factor: ")))
    (if (setq ds2 (getdist (strcat "Specify " (last sds) " distance <equal to " (car sds) ">: ")))
      (setq fc1 (getdist (strcat "Specify " (last sds) " factor: ")))
      (setq ds2 ds1 fc2 fc1))
    (vl-cmdf "_.pline"
	     "_non" (polar pnt (if (= (last sds) "RIGHT") 0. pi) (/ ds2 fc2))
	     "_non" pnt
	     "_non" (polar pnt (if (= (car sds) "RIGHT") 0. pi) (/ ds1 fc1)) ""))
  (princ)
  )
0 Likes
Message 3 of 17

abdulellah.alattab
Advocate
Advocate

thank you so much , if you can ? can i get downloadable file , i use mobile browser , can not download lisp file .

0 Likes
Message 4 of 17

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:
....
	  sds (if (> (- (cadr tmp) (cadr pnt)) 0)
....
ds1 (getdist (strcat "Specify " (car sds) " distance: ")) ....

That's comparing Y coordinates.  Shouldn't it be comparing X coordinates to decide whether the temporary point is to the right or left of the core point?

  sds (if (> (- (car tmp) (car pnt)) 0)

or, more simply:

sds (if (> (car tmp) (car pnt))

And I would suggest using the core point as reference base for a rubber-band line in the (getdist) functions, not only for the visual but to allow picking the distance on-screen from there if desired:

	  ds1 (getdist pnt (strcat "Specify " (car sds) " distance: "))

and similarly with the others.

Kent Cooper, AIA
Message 5 of 17

ВeekeeCZ
Consultant
Consultant

Thanks! 

Though not sure about the last one... Thinking that too many rubber bands could be rather confusing... So leaving that one up to the OP.

0 Likes
Message 6 of 17

abdulellah.alattab
Advocate
Advocate

thank you beekeeCZ it star well but after final ENTRY SOME THING WRONG HAPPEN ,....... NEED TO REVISON PLEASE 

0 Likes
Message 7 of 17

ВeekeeCZ
Consultant
Consultant

I have no idea what that could be. You gotta give me something more... copy-paste a command-line listing, video capture... something like that.

0 Likes
Message 8 of 17

abdulellah.alattab
Advocate
Advocate

error massege.JPGlines was not drawen

0 Likes
Message 9 of 17

abdulellah.alattab
Advocate
Advocate

in other forum , gentel man like you , try to help me 

 

see this link .

https://www.cadtutor.net/forum/topic/69414-draw-left-and-right-line-segment-from-point/

 

can you pack lisp final tested code as lisp file and send it for me 

0 Likes
Message 10 of 17

abdulellah.alattab
Advocate
Advocate

Sorry to bother you, I really need to this lisp, as soon as possible. I have a lot of work and time is short, it is generous from you if I keep helping me

0 Likes
Message 11 of 17

ВeekeeCZ
Consultant
Consultant
Accepted solution

Found it.

 

(defun c:Lines (/ pnt tmp sd1 sd2 ds1 ds2 fc1 fc2)
  
  (while (setq pnt (getpoint "\nSpecify a Core point <done>: "))
    
    (setq tmp (getpoint "\nPick a side: " pnt))
    (if (> (car tmp) (car pnt))
      (setq sd1 "RIGHT" sd2 "LEFT")
      (setq sd1 "LEFT"  sd2 "RIGHT"))
    (setq ds1 (getdist (strcat "Specify " sd1 " distance: "))
	  fc1 (getdist (strcat "Specify " sd1 " factor: ")))
    (if (setq ds2 (getdist (strcat "Specify " sd2 " distance <equal to " sd1 ">: ")))
      (setq fc2 (getdist (strcat "Specify " sd2 " factor: ")))
      (setq ds2 ds1 fc2 fc1))
    (vl-cmdf "_.pline"
	     "_non" (polar pnt (if (= sd2 "RIGHT") 0. pi) (/ ds2 fc2))
	     "_non" pnt
	     "_non" (polar pnt (if (= sd1 "RIGHT") 0. pi) (/ ds1 fc1)) ""))
  (princ)
  )
0 Likes
Message 12 of 17

abdulellah.alattab
Advocate
Advocate

I am sorry again ، can you upload lisp file in link , and your lisp as downloadable *.lsp file

0 Likes
Message 13 of 17

abdulellah.alattab
Advocate
Advocate

It works professionally ،
"but if you can make lisp add point object when start pick core point" . then upload your lisp file

I thank you first and for all who helped me.
I ask God that you will always be fine.

 

0 Likes
Message 14 of 17

cadffm
Consultant
Consultant
0 Likes
Message 15 of 17

ВeekeeCZ
Consultant
Consultant

@cadffm wrote:

@ВeekeeCZ 

Perfect, you can do the other Job too now

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-many-profissional-lisper-can-do-...

 


 

Thank you! I had that kind of feeling that this would be good... but perfect? No, it's not. But still appreciate your kind word(s). 

And the other thread... no, thanks! Don't like the shape.

0 Likes
Message 16 of 17

ВeekeeCZ
Consultant
Consultant
Accepted solution

@abdulellah.alattab wrote:

...
"but if you can make lisp add point object when start pick core point" ...

 


 

That's simple.

 

(defun c:Lines (/ pnt tmp sd1 sd2 ds1 ds2 fc1 fc2)
  
  (while (setq pnt (getpoint "\nSpecify a Core point <done>: "))
    (command "_.point" "_non" pnt)
    (setq tmp (getpoint "\nPick a side: " pnt))
...

 

0 Likes
Message 17 of 17

abdulellah.alattab
Advocate
Advocate
Accepted solution

final lisp code attached below , thank you beeKeeCZ

HINT : the left and right segment length modified to be (  distance multiplied by factor ) 

0 Likes