.NET

Reply
Valued Contributor
ognyandim
Posts: 59
Registered: ‎05-21-2008
Message 1 of 6 (270 Views)
Accepted Solution

Is it possible to change CommandMethodAttribute.GlobalName programmatically?

270 Views, 5 Replies
09-13-2011 02:44 AM

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.

Distinguished Contributor
Irvin
Posts: 112
Registered: ‎04-22-2009
Message 2 of 6 (262 Views)

Re: Is it possible to change CommandMethodAttribute.GlobalName programmatically?

09-13-2011 05:06 AM 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

*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 3 of 6 (238 Views)

Re: Is it possible to change CommandMethodAttribute.GlobalName programmatically?

09-13-2011 10:37 AM in reply to: ognyandim

You could just use a lisp function

 

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

 

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



(defun botsbuildbots() (botsbuildbots))
Board Manager
StephenPreston
Posts: 368
Registered: ‎05-22-2006
Message 4 of 6 (227 Views)

Re: Is it possible to change CommandMethodAttribute.GlobalName programmatically?

09-13-2011 11:45 AM 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
*Expert Elite*
dgorsman
Posts: 5,134
Registered: ‎10-12-2006
Message 5 of 6 (201 Views)

Re: Is it possible to change CommandMethodAttribute.GlobalName programmatically?

09-14-2011 11:49 AM 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.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


Valued Contributor
ognyandim
Posts: 59
Registered: ‎05-21-2008
Message 6 of 6 (178 Views)

Re: Is it possible to change CommandMethodAttribute.GlobalName programmatically?

09-15-2011 02:07 AM 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community