.NET

.NET

Reply
Valued Contributor
59 Posts
0 Kudos
Registered: ‎05-21-2008
Post 1 of 6
Accepted Solution

Is it possible to change CommandMethodAttribute.GlobalName programmatically?

284 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.

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).

 

Distinguished Contributor
112 Posts
10 Kudos
Registered: ‎04-22-2009
Post 2 of 6

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*
1,286 Posts
37 Kudos
Registered: ‎06-21-2004
Post 3 of 6

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))
ADN Support Specialist
433 Posts
67 Kudos
Registered: ‎05-22-2006
Post 4 of 6

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*
5,745 Posts
501 Kudos
Registered: ‎10-12-2006
Post 5 of 6

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
59 Posts
0 Kudos
Registered: ‎05-21-2008
Post 6 of 6

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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post