Choose between 2 lines before draw it.

Choose between 2 lines before draw it.

Anonymous
Not applicable
1,296 Views
17 Replies
Message 1 of 18

Choose between 2 lines before draw it.

Anonymous
Not applicable

Hi everyone. Maybe somebody can help me with this Lisp.

 

The rutine let me picks 2 points and draw 2 posibles plines. Then i choose one and erase.

The lisp works fine, but i dont like that draw the 2 lines and then erase one by choose.

 

It would be great if after a choosing the 2 points, autocad pre draw both plines and let my choose 

wich of them i want to keep.

 

Is there a way to do this?

 

Thanks in advance and regards

Clode

 

 

0 Likes
1,297 Views
17 Replies
Replies (17)
Message 2 of 18

john.uhden
Mentor
Mentor

I don't understand.  Unless you might be speaking of varying arcs between 2 points, you could have two lines or even polylines but the only difference would be that their start and end points would be reversed.  And one would lie directly on top of the other, so how would you distinguish them?

John F. Uhden

0 Likes
Message 3 of 18

Kent1Cooper
Consultant
Consultant

Change the end this way:

….
(command "pline" a1 i1 a2 ""); from original
(setq pl1 (entlast)) (command "pline" a1 i2 a2 ""); from original (setq pl2 (entlast)) (setq keep (car (entsel "\nSelect the one to keep: "))) (command "erase" (if (equal pl1 keep) pl2 pl1) "") (princ) )

[That depends on your successfully picking on the right one -- it could be modified to ask again if you miss.]

Kent Cooper, AIA
0 Likes
Message 4 of 18

Anonymous
Not applicable

Hi John, and thanks for the replay.

Sorry about my mistake in the explanation

The 2 polylines have 2 segments and 3 vertexs (thats why i attached the lsp, to see this) then there are only

two polylines (2 segments, 3 vertex and 45 grads between segments) that connect the two point.

 

Thanks again for your time.

Clode

0 Likes
Message 5 of 18

Anonymous
Not applicable

@Kent1Cooper  ha escrito:

Change the end this way:

….
(command "pline" a1 i1 a2 ""); from original
(setq pl1 (entlast)) (command "pline" a1 i2 a2 ""); from original (setq pl2 (entlast)) (setq keep (car (entsel "\nSelect the one to keep: "))) (command "erase" (if (equal pl1 keep) pl2 pl1) "") (princ) )

[That depends on your successfully picking on the right one -- it could be modified to ask again if you miss.]


Hi Kent, thanks by the replay.

Your idea works fine, but the lisp still draw the 2 polys and then deleted one. im trying that

lisp looks more profesional. It means that i looking a way to preview one or the other poly

by example alternating since i move the mouse and when i click appears the last i see it.

 

Sorry but me english, i hope you understand my

 

Thanks.

Clode

0 Likes
Message 6 of 18

Anonymous
Not applicable

I am confused are you trying to join 1 end ? if so then it can be done pretty easy. 1 line.

0 Likes
Message 7 of 18

john.uhden
Mentor
Mentor

I don't know what it's for, but I rather like your code.

I think the only way to avoid the choice is for you to write a list of properties or conditions or relationships that you have in your head to make a choice.

John F. Uhden

0 Likes
Message 8 of 18

john.uhden
Mentor
Mentor

Maybe now I get it... You want to pick the one to keep, not the one to erase.

(command "pline" a1 i1 a2 "")
(setq ss (ssadd (entlast)))
(command "pline" a1 i2 a2 "")
(ssadd (entlast) ss)
(setq e (car (entsel "\nSelect the pline to keep: ")))
(command "erase" (ssdel e ss) "")
(princ)

John F. Uhden

0 Likes
Message 9 of 18

Anonymous
Not applicable
I attach an image of the 2 posible polys from 2 points.
There are the 2 posibles línes from where o want to choose beforw draw it.

Clode

Clode
0 Likes
Message 10 of 18

john.uhden
Mentor
Mentor

I guess I still don't understand how you can make a choice when there is nothing yet to choose from, unless there are characteristics that you can define to apply to the choice.

John F. Uhden

0 Likes
Message 11 of 18

Anonymous
Not applicable
John, of you can see the image I attach you Will see the 2 options.
Anyway, giving 2 points, There are 2 ways to make a polyline of 2 segments and 45 degrees in between them that join booths points. This is the choice.

Regards
0 Likes
Message 12 of 18

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

 

.... i looking a way to preview one or the other poly

by example alternating since i move the mouse and when i click appears the last i see it.

 

….

That can be done using (grread) and a temporary (entmakex), as in the attached PP.lsp file.  It does not yet include things like error handling, but it seems to work in limited testing.

 

The way it decides which one to show as you move the mouse is by which of the two possible middle-vertex locations is closer to the mouse location. It could probably be altered to choose by which side of the end-to-end line the mouse is on, if that would be better.

Kent Cooper, AIA
Message 13 of 18

john.uhden
Mentor
Mentor

Your wizardry is very cute.  I like that kind of inventiveness.

Gotta get that *error* function in there, though.

John F. Uhden

0 Likes
Message 14 of 18

john.uhden
Mentor
Mentor

I was just thinking that a slightly better way might be to entmakex both of them (e1 and e2) just once but then alternately entdel one or the other depending on the cursor location.  For you lurkers, the entdel function can be used to delete and to undelete an object by its entity name.

John F. Uhden

0 Likes
Message 15 of 18

Anonymous
Not applicable

@Kent1Cooper  ha escrito:

@Anonymous wrote:

 

.... i looking a way to preview one or the other poly

by example alternating since i move the mouse and when i click appears the last i see it.

 

….

That can be done using (grread) and a temporary (entmakex), as in the attached PP.lsp file.  It does not yet include things like error handling, but it seems to work in limited testing.

 

The way it decides which one to show as you move the mouse is by which of the two possible middle-vertex locations is closer to the mouse location. It could probably be altered to choose by which side of the end-to-end line the mouse is on, if that would be better.


Hi Kent, and thanks for the replay.

 

Yes I think the solution goes that way. I will check your lsp soon and then tell you about it.

 

Thanks again and regards.

Clode

0 Likes
Message 16 of 18

john.uhden
Mentor
Mentor
I think what @Kent1Cooper did is very clever, but I think it worked more
easily with showing both and picking which one to keep. I mean easier for
the user too.
Once again, though, if there were rules that would dictate which one was
desired over the other, then there would be no need for a user's choice,
which allows for a 50% failure rate.

John F. Uhden

0 Likes
Message 17 of 18

Anonymous
Not applicable
John, the decission of the election depends of the design of other parte of geometry that Who is drawing must make a choice.
Anyway, that you say that shows the 2 options and pick is not a bad idea.

Thanks!!
0 Likes
Message 18 of 18

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

 

That can be done using (grread) and a temporary (entmakex), as in the attached PP.lsp file.  ....


Here's an enhanced version that shows you both Polylines at all times, "featuring" the one that will remain if you pick.  It still chooses which to feature based on distance to the "shoulders" rather than on which side of the center-line the cursor is, but that could be changed.  If you use a white background [I use black], consider changing the 252's to 254's or some other pale color, possibly some other-than-grey variety.

Kent Cooper, AIA
0 Likes