Enforce Lisp execution order within a macro

Enforce Lisp execution order within a macro

pablo.odriozola
Contributor Contributor
517 Views
8 Replies
Message 1 of 9

Enforce Lisp execution order within a macro

pablo.odriozola
Contributor
Contributor

Hi there,

I've created 2 custom commands for AutoCAD as lisp files. When I run the macro:

 

^C^C_COMMAND-1;COMMAND-2

 

I get an alert that is coming from the second command before the first command is executed. How can I enforce the order of execution so that the alert from the second command only shows after the first command is fully executed?

Thanks for your help once again!

0 Likes
518 Views
8 Replies
Replies (8)
Message 2 of 9

Kent1Cooper
Consultant
Consultant

@pablo.odriozola wrote:

....

^C^C_COMMAND-1;COMMAND-2

I get an alert that is coming from the second command before the first command is executed. How can I enforce the order of execution so that the alert from the second command only shows after the first command is fully executed? ....


Does the first one partially execute?  Or does it fail entirely, and the macro then moves on to the second one?

 

[At first I suspected the latter because of the _underscore prefix on the first command.  That's not really appropriate to a custom command name.  It's to make native AutoCAD commands in their English-version names work in AutoCAD for other languages.  But I find with some of my custom commands that the underscore prefix doesn't cause any trouble.]

 

Or, does the first command fully execute eventually, but not until after the alert coming from the second command?

Kent Cooper, AIA
0 Likes
Message 3 of 9

pablo.odriozola
Contributor
Contributor

Hi Kent,

Answering your question, first I get the alert from the second command and then the first one gets executed (correctly)

0 Likes
Message 4 of 9

Kent1Cooper
Consultant
Consultant

Is there some way of determining whether it's only something like a delay in display updating until after the entire macro is done, and the first command is actually executed before the second one, but you just don't see it until after?

Kent Cooper, AIA
0 Likes
Message 5 of 9

pablo.odriozola
Contributor
Contributor

It's not just a delay because the alert would be different in case the first command was fully executed before the second one

0 Likes
Message 6 of 9

Sea-Haven
Mentor
Mentor

You may have to resort to loading a script.

 

(load "Mycommands")

Coomand1

Coomand2

0 Likes
Message 7 of 9

Moshe-A
Mentor
Mentor

@pablo.odriozola  hi,

 

To debug, add these 2 lines to each of your commands:

run the macro and tell us what is the result?

 

Moshe

 

(defun c:command-1 ()
 (getstring "\nEnter command-1...")

 ; your command-1 code start here
 ; .....
 ; .....
 ; .....
  
 (getstring "\nAbout to exit command-1...")

 (princ)
)


(defun c:command-2 ()
 (getstring "\nEnter command-2...")

 ; your command-2 code start here
 ; .....
 ; .....
 ; .....
  
 (getstring "\nAbout to exit command-2...")

 (princ)
)

 

0 Likes
Message 8 of 9

Sea-Haven
Mentor
Mentor

Nice idea I use (alert "Command 1 has completed") same thing forces a stop. 

0 Likes
Message 9 of 9

Moshe-A
Mentor
Mentor

@Sea-Haven 

 

thank you

 

after I sent that I realised that (getstring) requires a backslash char "\" in menu macro 😀

 

 

0 Likes