Jump to content
lido

AutoCAD built-in command list with AutoLISP

Recommended Posts

lido

Hello all!

I have an AutoLISP code that goes to the client along with drawings. The code contains a sequence for attribute editing with either EATTEDIT built-in command or an AutoLISP snippet.

 

On this stage, I don't know if the EATTEDIT built-in command is implemented under the client CAD platform, so that I must check the availability of the command.

 

Is there any possibility to obtain via AutoLISP a complete list of AutoCAD internal (built-in) commands?

 

Thank you in advance.

Share this post


Link to post
Share on other sites
lido

Sorry, but atoms-family function don't return the built-in command names. Please try it.

Share this post


Link to post
Share on other sites
rkmcswain

Is there any possibility to obtain via AutoLISP a complete list of AutoCAD internal (built-in) commands?

 

ARX command, "C" option.

 

Here is an entire thread on this topic, including some good lisp routines.

Share this post


Link to post
Share on other sites
rlx
Sorry, but atoms-family function don't return the built-in command names. Please try it.

 

 

oh darn... hope other reply does better... maybe vl-cmdf can offer a quick test because it first tests if a command can be successful before it executes it else just check autocad version

Share this post


Link to post
Share on other sites
lido

I know the trick with ARX, option "C".

EATTEDIT still missing from the list (AutoCAD 2015). Please give it a try.

Share this post


Link to post
Share on other sites
ronjonp
Posted (edited)

Not a full list .. but here's a quick check:

...

Edited by ronjonp
*removed code suggestion does not work DOH!

Share this post


Link to post
Share on other sites
Roy_043

How about?:

(getcname "_eattedit")

Share this post


Link to post
Share on other sites
lido

(vl-cmdf "abcde") return: Unknown command "abcde". Press F1 for help. T

(command "abcde") return: Unknown command "abcde". Press F1 for help. nil

Finally, always vl-cmdf function return T and command function return nil.

How could I manage an error like "Unknow command" without an error code??

 

Testing the AutoCAD version may be a path... But if the client uses an other CAD platform? First test the platform (PROGRAM system variable). Then test the version (VERNUM system variable) and decide if EATTEDIT is implemented or not by reading specific CAD manuals. No, please...

Share this post


Link to post
Share on other sites
ronjonp

Use Roy's suggestion .. or better yet get rid of command calls in your code. ;)

Share this post


Link to post
Share on other sites
rlx
(vl-cmdf "abcde") return: Unknown command "abcde". Press F1 for help. T

(command "abcde") return: Unknown command "abcde". Press F1 for help. nil

Finally, always vl-cmdf function return T and command function return nil.

How could I manage an error like "Unknow command" without an error code??

 

Testing the AutoCAD version may be a path... But if the client uses an other CAD platform? First test the platform (PROGRAM system variable). Then test the version (VERNUM system variable) and decide if EATTEDIT is implemented or not by reading specific CAD manuals. No, please...

 

mabe app needs rewrite or better error catching

 

 (setq test (vl-catch-all-apply 'command-s (list "eattedit"))) vs (setq test (vl-catch-all-apply 'command-s (list "lido-edit"))) 

 

but if client uses other CAD platform you're even further from a solution. but doesn't (Roy's) getcname work?

Share this post


Link to post
Share on other sites
lido

I tried these functions before posting on this forum!

Under AutoCAD 2015:

(getcname "_eattedit") return nil

(getcname "eattedit") return nil

 

(= (type 'eattedit) 'sym) return T

(= (type 'abcde) 'sym) return T

Share this post


Link to post
Share on other sites
ronjonp
I tried these functions before posting on this forum!

...

Then learn to ask a better question. :lol:

 

"Describe the diagnostic steps you took to try and pin down the problem yourself before you asked the question."

Share this post


Link to post
Share on other sites
lido

Catching error with vl-catch-all-apply and vl-catch-all-error-p functions are OK but don't solve the problem entirely. Because of command-s function. Using command or vl-cmdf functions, fails.

Unfortunately, the command-s function is not implemented under older AutoCAD releases (e.g. AutoCAD 2000) or under some CAD platforms (e.g. ZWCAD).

So, in my opinion, the only way to solve the problem is by getting that damn list of all built-in AutoCAD commands. It is possible or not?

Share this post


Link to post
Share on other sites
lido

Sorry mr. ronjonp for wasting your time.

Aggression cannot, under any circumstances, solve none problem!

Share this post


Link to post
Share on other sites
rlx

Maybe a certain L(ist) M(anipulator) has some bright idea or knows of a undocumented command. But I am curious ,if and when you know eattedit is not available , what are you gonna do with this knowledge. Just display a message with sorry command not available or do you have a backup routine? I think there are more than enough people on this site able and willing to help you to rewrite your routine or just the part you need. Just 'be kind & rewind' ...

Share this post


Link to post
Share on other sites
Roy_043

To my knowledge there is no way to obtain a list of command names via Lisp code.

 

For _eattedit and other commands that require user input something like this should work (on most CAD platforms I believe):

(defun CommandAvailable_P (cmd / ret)
 (setvar 'cmdecho 0)
 (command cmd)
 (setq ret
   (if (zerop (getvar 'cmdactive))
     (progn
       (princ "\r") ; Remove: 'Unable to recognize command "ABC". Please try again.' prompt.
       nil
     )
     (progn
       (command nil)
       T
     )
   )
 )
 (setvar 'cmdecho 1)
 ret
)

Share this post


Link to post
Share on other sites
Roy_043

FYI: getcname works fine in BricsCAD:

(getcname "_eattedit") => "EATTEDIT"
(getcname "_doesnotexist") => nil

Share this post


Link to post
Share on other sites
lido

Thank you very much Roy_043.

Using the system variable CMDACTIVE is the key!

I never think about this approach. Brilliant.

 

Thank you one more time.

Share this post


Link to post
Share on other sites
hanhphuc
Posted (edited)

Just test only..

[color="green"];At this level we can list out [/color] 
([color="blue"]vl-registry-descendents[/color]  (strcat "HKEY_LOCAL_MACHINE\\"
	 (vlax-product-key)
	 "\\Applications\\")
 )


[color="green"];but why this level doesn't work ???[/color]
([color="blue"]vl-registry-descendents[/color]
 (strcat "HKEY_LOCAL_MACHINE\\"
  (vlax-product-key)
  "\\Applications\\"
  "AcEAttEdit"
  [color="red"]"\\Commands"[/color]
  ) 
 ) 

 

another approach

(defun foo (app [b][color="red"]ac[/color][/b] cmd)
 (and (setq app (findfile app))
      ([color="blue"]vl-registry-read
[/color]	 (strcat "HKEY_LOCAL_MACHINE\\"
	 (vlax-product-key)
	 "\\Applications\\"
	 [color="red"][b]ac
[/b][/color]		 "\\Commands")
	 (strcase cmd )
	 ) 
 
      ) 
 )

 

_$ (foo "AcEAttEdit.arx" "AcEAttEdit" [color="red"]"EATTEDIT"[/color])
[color="blue"][b]T[/b][/color]
_$ (foo "AcTable.arx" "AcadTable" [color="red"]"EATTEDIT"[/color])
[color="blue"][b]nil[/b][/color]
_$ (foo "AcTable.arx" "AcadTable" [color="red"]"TINSERT"[/color])
[b][color="blue"]T[/color][/b]

Edited by hanhphuc
added ac

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×