[LISP] How to check if a CAD command exists?

[LISP] How to check if a CAD command exists?

iBlachu
Advocate Advocate
735 Views
9 Replies
Message 1 of 10

[LISP] How to check if a CAD command exists?

iBlachu
Advocate
Advocate

How to check if a given CAD command exists?

 

Example.
I don't know if a given command called by COMMAND is called _-TOOLBAR or _-TOOLBARS.

 

So I want to check if one of the following expressions does not generate an error and which is correct:
(command "_-TOOLBAR" "MY" "_s")
(command "_-TOOLBARS" "MY" "_s")

 

How to check if the CAD command is called TOOLBAR or TOOLBARS?

This is just an example, but I mean the principle, is it possible to check it?

0 Likes
Accepted solutions (1)
736 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

Possibly 

 

(getcname "toolbar") 

 

 

Message 3 of 10

iBlachu
Advocate
Advocate

Thank you, that's what I meant.

0 Likes
Message 4 of 10

Kent1Cooper
Consultant
Consultant

For (defun)'d custom command definitions, you can do this kind of thing:

(if C:YourCommandName

  (... do what you want ....); then

  (prompt "\nThat command is not defined."); else

)

Kent Cooper, AIA
0 Likes
Message 5 of 10

john.uhden
Mentor
Mentor

Or...

(type c:YourCommandName) will return

'LIST if it was defun-qed

'SUBR if it was defuned

'EXSUBR if it came from an ARX.

(At least I think that's the way it works)

 

John F. Uhden

0 Likes
Message 6 of 10

Sea-Haven
Mentor
Mentor

Same with plain defuns that have been loaded.

 

(type ah:getvalsm)
SUBR

 

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))

0 Likes
Message 7 of 10

john.uhden
Mentor
Mentor

Sorry for the delay, Alan.

We were visiting my daughter & family in Maine.

What do you mean by a "plain defun?"

John F. Uhden

0 Likes
Message 8 of 10

Sea-Haven
Mentor
Mentor

No C: so its not a defun to be used when typed on command line. Rather called by lisp etc.

 

Yes can type (c:mydefun)

0 Likes
Message 9 of 10

vladimir_michl
Advisor
Advisor

If you mean an internal command, yes it can be checked by

(getcname "_-TOOLBAR")

But bear in mind it is not 100% reliable - some existing commands may return nil. E.g. MTEXT.

 

Vladimir Michl, www.arkance-systems.cz - www.cadforum.cz

 

0 Likes
Message 10 of 10

john.uhden
Mentor
Mentor

@iBlachu 

I just remembered.  You could turn on LOGFILEMODE and run the ARX command, which will spit out a list (in doses like the LIST command) of all the AutoCAD (and vertical) commands, or only those that match a wild card pattern of your choice.  Then you could cut'n'paste the list into a text file or whatever.

John F. Uhden

0 Likes