Hard enter/accept defaults on a Sub LISP

Hard enter/accept defaults on a Sub LISP

Jason.Rugg
Collaborator Collaborator
863 Views
7 Replies
Message 1 of 8

Hard enter/accept defaults on a Sub LISP

Jason.Rugg
Collaborator
Collaborator

I have lisp routine that calls out a sub c:lisp routine. Normally if I just run the sub lisp by itself it asks three questions and I can very quickly hit enter 3 times to accept the defaults. Now in my new lisp, how can I code these three rapid hard enters? With a normal command I can do (command "command" "" "" "") but that wont work since this is not an actual ACAD command.

 

I thought maybe I could do something like this:

setq Ent ("" "" "")

(c:lisp Ent Ent Ent)

 

But that doesn't work.

 

Any suggestions?

0 Likes
864 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

Make a menu-macro for a button or shortcut. That's the best and easier way.

Nothing, like suggested, exists.

More complicated a with limitations is to use vla-sendcommand method.

0 Likes
Message 3 of 8

CodeDing
Advisor
Advisor

@Jason.Rugg ,

 

The Correct way to accomplish what you desire would be to have the command version of your lisp (c:LISP) and a function version that allows for parameters (Lisp p1 p2 p3). this would allow you to use what you desire in the correct form necessary. You might not even need 2 versions if you create effective sub routines to assist you in appropriate situations.

 

The Incorrect way, but can be used in a pinch, to accomplish what you desire might be accomplished like so (notice the 3 spaces, but this is NO guarantee):

(defun c:TEST ( / acObj acDoc)
(setq acObj (vlax-get-acad-object))
(setq acDoc (vla-get-ActiveDocument acObj))
(vla-SendCommand acDoc "MYCOMMAND   ")
);defun

Normally when a routine has paused for user input, it is because the desired outcome is unknown... But it sounds like you know the desired outcome, so why not just rewrite the sub routine?

 

Best,

~DD

0 Likes
Message 4 of 8

Kent1Cooper
Consultant
Consultant

Another approach:  make a different version of your C:lisp sub-routine that has those default values built in, without  asking the questions, and call that one from your "outer" routine.

Kent Cooper, AIA
Message 5 of 8

Jason.Rugg
Collaborator
Collaborator

This is actually the approach that I am taking. I don't want to change the original as it is widely used in our organization with different values but the lisp that I am making that uses this as a sub routine will always have the same values.

0 Likes
Message 6 of 8

Jason.Rugg
Collaborator
Collaborator

This bit of code you provided works beautifully. Why would this be considered incorrect if it actually works?

0 Likes
Message 7 of 8

CodeDing
Advisor
Advisor

@Jason.Rugg ,

 

That approach is considered incorrect because, in the case of your situation, the vla-sendcommand method after an instance of user input is encountered, your lisp will begin to run asynchronously. While this may not often, if ever, affect the operation of your lisp, it still increases chances of error. And in all programming communities a common theme is to always reduce every potential for error (due to the unpredictable nature of human action). Which, in your case, to reduce the level or chance of error would be to create your own custom sub-routine since you (presumably) have access to the original code. This will only help you in the long run.

 

Hope that helps.

 

Best,

~DD

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

One thing that may help is using, this is an example of starting a pline and then doing something it could be a choice pick points, use a list etc.

 

(command "_pline")
(while (= (getvar "cmdactive") 1 ) 
0 Likes