Is it possible to change CommandMethodAttribute.GlobalName programmatically?

Is it possible to change CommandMethodAttribute.GlobalName programmatically?

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

Is it possible to change CommandMethodAttribute.GlobalName programmatically?

Anonymous
Not applicable

Is it possible to change CommandMethodAttribute.GlobalName programmatically?

 

I want to have the ability to change the shortcut just like I can change the polyline command from "pl" to just "p".

That will be very useful option that gives the user the ability to customise the interface himself.

 

I know how to create menu, toolbar, menumacro and a toolbarButton. I know how to createa a method with [CommandMethodAttribute("xyz")]. Now I want to change "xyz" to "abc".


I have already tried tons of code on the net, samples from the ObjectARX but did not find any that is useful.

I see that such a feature is built-in AutoCAD and I suppose that it is possible.

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

Anonymous
Not applicable
Accepted solution

Just add a newline to your acad.pgp file. Here you can manage shortcuts to command. It's user editible.

 

Kind regards,

 

irvin

0 Likes
Message 3 of 6

arcticad
Advisor
Advisor
Accepted solution

You could just use a lisp function

 

(defun C:abc ()
 (command "xyz") 
 (princ)
)

 

---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 4 of 6

StephenPreston
Alumni
Alumni
Accepted solution

This property is read-only - and for good reason.. The command global name is supposed to be just that - a name for the command that is invariant across all versiosn and instances of AutoCAD. Trying to change it at run time will then break any MenuMacros or scripts the user has created to use with your command. Better is to use one of the techniques suggested in the other replies, or make use of the local name to read a local name for your command from a resource string (The LoxalizedNameId is read-only as well, but you can edit resources used by your DLL).

 

Cheers,

Stephen Preston
Autodesk Developer Network
0 Likes
Message 5 of 6

dgorsman
Consultant
Consultant

Verbose naming of commands is a good thing.  Not only do some users get cranky when their own "P" or "PL" alias can't be used, you can never tell if some unanticipated third-party application will attempt to hijack that alias, leading down the rabbit hole to debugging and configuration hell.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 6 of 6

Anonymous
Not applicable

Thanks a lot. You have provided professional answers.

 

I will try with .pgp and lisp and will see what fits in.

 

I have finished the interface rebuiding class and I provide it here as an attachment ( it is made for rebuidling interface against a custom XML).It can bu customized for ribbons, but for now I will stick to toolbars.

 

I`ll be glad if this code is useful to you.

0 Likes