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.
Solved! Go to Solution.
Solved by adeuley. Go to Solution.
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,
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.