Revit API Forum
Welcome to Autodeskā€™s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

Override Command with a custom Command

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
adeuley
620 Views, 2 Replies

Override Command with a custom Command

I am trying to override the duplicate command with a enew command of mine. I've looked at the examples in the help menu and can get it to override the command. My problem is trying to get the current selection. I think my issue is trying to get from UIControlledApplication to UIDocument. My thought was to just have it fire a new external command that I can then easily get the UIDocument but I can't seeem to figure out how to post my external command. All of the examples I see show the command being overriden with a simple taskdialog box. I actually want it to before a different action. Any help is greatly appreciated. Thanks.

2 REPLIES 2
Message 2 of 3
Joe.Ye
in reply to: adeuley

 

I am  kind of confused.

Would you please clarify these questions?

1# You just want to override Revit's existing command, and you already found the way to do so.

2#  You want to get the current selection and get the selected elements.

 

If the answer is yes, hope the attached sample can help you. This sample code is from SDK.

 

You can get the UIApplication from the sender argument.

 

  void binding_Executed(object sender, Autodesk.Revit.UI.Events.ExecutedEventArgs e)
        {
           UIApplication uiApp = sender as UIApplication;

           ...

         }

 

then get the selection object.

 

Selection sel = uiApp.ActiveUIDocument.Selection;

 

 

Hope this helps,



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 3 of 3
adeuley
in reply to: Joe.Ye

I was trying to figure out how to get the selection from within an external application. I figured out how to override the duplicate command. I was trying to figure out how to determine what the name of the family was that was selected. I want to only sometimes override the command. I was able to figure out how to get the selection though. I then was trying to unbind the overrride and post the duplicate command but apparently it isn't a postable command. Which makes sense because you would need to have something selected in order to use the command. I ended up rewriting the duplicate command and got the exact result I wanted. Sometimes the command is overriden  and sometimes it acts normally.

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


Rail Community