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.
Solved! Go to Solution.
Solved by StephenPreston. Go to Solution.
Solved by arcticad. Go to Solution.
Just add a newline to your acad.pgp file. Here you can manage shortcuts to command. It's user editible.
Kind regards,
irvin
You could just use a lisp function
(defun C:abc () (command "xyz") (princ) )
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).
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.
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.
Can't find what you're looking for? Ask the community or share your knowledge.