.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is it possible to change CommandMethodAttribute.GlobalName programmatically?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
ognyandim
847 Views, 5 Replies

Is it possible to change CommandMethodAttribute.GlobalName programmatically?

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.

5 REPLIES 5
Message 2 of 6
Irvin
in reply to: ognyandim

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

 

Kind regards,

 

irvin

Message 3 of 6
arcticad
in reply to: ognyandim

You could just use a lisp function

 

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

 

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



(defun botsbuildbots() (botsbuildbots))
Message 4 of 6
StephenPreston
in reply to: ognyandim

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
Message 5 of 6
dgorsman
in reply to: ognyandim

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
ognyandim
in reply to: Irvin

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.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost