Lisp to create continuous line - helpp

Lisp to create continuous line - helpp

Anonymous
Not applicable
1,038 Views
5 Replies
Message 1 of 6

Lisp to create continuous line - helpp

Anonymous
Not applicable

Hi,

 

Im in trouble with this lisp.

1. draw line, as many segments as the user wants;

2. to stop the line drawing, hit enter (the normal commmand it already happen);

3. prompt something, like "line has been created.";

Iam new at programming lsp, so any help is greatly appreciated.

 

 
0 Likes
Accepted solutions (2)
1,039 Views
5 Replies
Replies (5)
Message 2 of 6

cadffm
Consultant
Consultant
Accepted solution

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/polyline-pick-and-user-input/m-p/909...

(command "_.line")
(while (eq 1 (getvar "cmdactive"))
(prompt "\nPick point: ")
(command pause)
)

Sebastian

Message 3 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

A refinement....

 

It doesn't need to prompt for the next point -- the Line command will take care of that for you.  Letting it do so preserves the visibility in the prompt of the Undo and [after at least two segments] Close options.

 

And the CMDACTIVE System Variable has various values, so you don't need to check for its being 1 specifically, but anything greater than zero.

 

(command "_.line")
(while (> (getvar 'cmdactive) 0) (command pause))
(prompt "\nLine has been created.")
(princ)
Kent Cooper, AIA
Message 4 of 6

Anonymous
Not applicable

Thank you guys !

I didn't knew the "cmdactive". It will be very helpfull in my future codes.

 
0 Likes
Message 5 of 6

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

..I didn't knew the "cmdactive". It will be very helpfull in my future codes.

 

Guess what, you don't even need that.

 

(command-s "_.line")
(prompt "\nLine has been created.")
Message 6 of 6

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:
Guess what, you don't even need that.
(command-s "_.line")
(prompt "\nLine has been created.")

I keep forgetting about that, because the description of the (command-s) function sounds  as though it shouldn't work that way -- particularly this:

 

"Token streams fed in a single command-s expression must represent a full command and its input."

 

But in fact it does work as suggested.  I think Autodesk needs to revise the description [or change the way it works to agree with the description].

 

Also, (command-s) is not present in older versions [pre-2014 or something like that?].

Kent Cooper, AIA