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 within dialogue

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
808 Views, 6 Replies

Override Command within dialogue

I have written a script that I want to run whenever someone tries to duplicate a type. I can override the duplicate from the right click menu within the project browser. My question is how to I override the duplicate command within the type properties box. Any help is appreciated. 

6 REPLIES 6
Message 2 of 7
jeremytammik
in reply to: Anonymous

Dear Adeuley,

 

Happy New Year!

 

Thank you for your query.

 

How do you override the duplicate from the right click menu within the project browser?

 

What is the duplicate command within the type properties box? Is that a button that the user clicks?

 

As far as I know, the Revit API does not provide any support for this.

 

If you really want to achieve it at any price, you could almost certainly use the Windows API to detect that specific button click and trigger your code from there.

 

It would not be in a valid Revit API context, though.

 

Therefore the question: what are you doing in your script? Does it make use of the Revit API?

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 7
Revitalizer
in reply to: Anonymous

Dear adeuley,

duplicating an ElementType may be intercepted using an IUpdater.

This IUpdater could be tailored to be fired on change or creation of elements plus you can assign a fine-tuned filter, saying for ElementType.
I doubt if you can create new Elements in its Execute method, but you could change the Parameters of these newly created ElementTypes.

If you just want to be noticed without changing the database, this may be your way.
Once notified, you may do with the popping up ElementType props dialog whatever you want.


Best regards,
Revitalizer

 

EDIT: it may be that this IUpdater will be fired AFTER user has confirmed the new ElementType's name, or even later, after closing the ElementType's props dialog.

If so, please forget my suggestion since it won't work 😞




Rudolf Honke
Software Developer
Mensch und Maschine





Message 4 of 7
Anonymous
in reply to: jeremytammik

Happy New Year to you too Jeremy.

 

I overrode the duplicate command in the right click menu but looking at the journal and figuring out what command was being called. I then find the RevitCommandId and then use AddInCommandBinding to override it. 

 

I've looked in the journal and can't seem to find the the command that does the duplicate command within the type properties windows. It seems to me like it all happens in the middle of a transaction. Nothing is really duplicated until you hit the Ok or Apply button, but I'm not completely positive.

 

As far as what I am doing with the duplicate command. It completely makes us of the Revit API. I am overriding it when some tries to duplicate specific families. When it is not the proper family I duplicate the element as normal. When it is the right family I am forcing them into a custom dialogue box. Once they click create within the dialogue box it creates a new type within that family and it also create a new type within a detail item family that represents the 3D element in a 2D drafting view. I then copy the element Id of each object into a specific parameter. I then have an IUpdater running that gets triggered when certain parameters are changed. This then changes that same parameter in both the 3D element and the 2D element, thus keeping them in sync. 

 

I'd rather stay within the Revit API if I could. It isn't a make or break kinda thing. I'm just trying to intercept every way some can duplicate an element thru the UI.

 

On a side note, The Revit API is my first adventure into programming and you and your blog has helped me tremendously. I've learned to love programming especially the creation and troubleshooting aspects. So thank you for all of your help.

Message 5 of 7
jeremytammik
in reply to: Anonymous

Dear Adeuley,

 

Congratulations. That sounds like a pretty advanced use for a first Revit add-in project!

 

Thank you for your appreciuation. I am very glad The Building Coder is proving useful for you.

 

I would suggest following Revitalizers recommendation, then, and go with the DMU dynamic updater framework.

 

It enables you to react to specific events and make changes to the database within the same transaction that triggers the event.

 

The DocumentChanged event would also enable you to detect the type duplication, but not make changes to the database:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.31

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 7
Revitalizer
in reply to: jeremytammik

Hi Jeremy,

 

as adeuley already said, "Nothing is really duplicated until you hit the Ok or Apply button".

That means hitting the "Duplicate" button won't fire an IUpdater.

IUpdater won't work, in this case.

 

I think he will really need to intercept the mouse click itself, using some sort of Windows API, as you suggested above.

 

 

Best regards,

Rudi

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 7 of 7
Anonymous
in reply to: Revitalizer

I believe that you are correct that I would need to intercept the mouse click. I think for the time being I will just tell the designers not to duplicate anything within the Type properties dialogue. Thanks for all of your help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community