Launch Revit command to edit filters without using PostCommand

Launch Revit command to edit filters without using PostCommand

m.vallee
Advocate Advocate
1,214 Views
7 Replies
Message 1 of 8

Launch Revit command to edit filters without using PostCommand

m.vallee
Advocate
Advocate

Hi,

 

In my addin's form, which enables the user to select a rule-based filter or a selection filter from the document existing filters, I want to add a "Edit" button that launches the "Edit Selection" Revit command.

 

I know I could use a PostCommand, but then the edition window would appear when control returns from the current API context (i.e. when the main form is closed), which is not what I want.

 

I would like the user to be able to click on the "Edit" button, add/remove/edit some filters with the Revit native command, then go back to my main form and see the updated list of exisiting filters.

 

Is there a way to do so ?

 

Thanks.

Maxime

0 Likes
Accepted solutions (1)
1,215 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk

Dear Maxime,

 

Thank you for your query.

 

I do not believe the Revit API alone will enable you to achieve this.

 

I do however think you could achieve what you wish using PostCommand to launch the built-in command and add some custom Windows API functionality to cancel specific forms that you do not want the user to see or interact with.

 

Check out my solution to dismiss a dialogue using Windows API:

 

https://thebuildingcoder.typepad.com/blog/2009/10/dismiss-dialogue-using-windows-api.html

 

The approach suggested there is very flexible.

 

I hope this helps.

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 3 of 8

m.vallee
Advocate
Advocate

Hi Jeremy,

 

Thanks for your idea.

I have read your article on your blog, but I can't see how this could be used to obtain the intended behaviour.

 

  • If I hide the main form when clicking on the button (and let's say my form is a modeless form), how could the PostCommand be processed, since control has not been returned from Revit API context ?
  • If I close the main form when clicking on the button, in order for the PostCommand to be processed, then how could I catch the closing event of the "Edit selection" Revit command to relaunch the addin (and showing the form with updated values) ?

Maxime

0 Likes
Message 4 of 8

jeremytammik
Autodesk
Autodesk

Dear Maxime,

 

Thank you for your update.

 

I don't know all the details of all the interactions in the workflow you target, nor do I fully understand your reply or confusion, so I'll just answer one part that I assume might be relevant, the following question:

 

Question: My add-in implements two pieces of functionality, A and B. However, between A and B, I also need to execute some built-in Revit functionality, e.g., a built-in command R. How can I achieve that, please?

 

Answer: Use PostCommand in conjunction with the Idling event. Just before terminating A, subscribe to the Idling event before launching R via PostCommand. In the Idling event handler, unsubscribe from Idling again and execute B.

 

I hope this helps.

 

I wish you a happy weekend!

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 5 of 8

m.vallee
Advocate
Advocate

Hi Jeremy,

 

Thanks for your answer.

 

Sorry if I was not clear enough. My workflow is slightly different from the one you describe.

My plugin starts with showing a modal form so that the user can select entry data. These entry data consist in a list of filters. If the list doesn't satisfy the user, I want him to be able to click on a "Edit" button to go to the native "Edit selection" command (in the UI you do "Manage" > "Selection" > "Edit" - please see the corresponding command below). 


edit filters.png

 

There he can add/edit/rename/delete filters. When he closes the command, I want him to go back to the initial modal form and see the updated list of filters. So I don't think what you describe can be applied to my needs...

 

Maxime

0 Likes
Message 6 of 8

m.vallee
Advocate
Advocate
Accepted solution

Hi,

 

A quick update to say I solved my problem using PostCommand together with Idling events. I used the wrapper RevitCommandEndedMonitor, kindly given by BobbyCJones here : https://forums.autodesk.com/t5/revit-api-forum/a-question-about-suppressing-warning-messages-in-revi... 

 

Thanks.

 

Maxime

0 Likes
Message 7 of 8

jeremytammik
Autodesk
Autodesk

Wow, cool!

 

Congratulations!

 

Thank you for letting us know!

 

I don't think Bobby's solution ever made it to the blog, and according to what you say, it might deserve a space there.

 

Can you package a simplified version of your solution as a minimal reproducible case that we can share on the blog as a demonstration of how to use Bobby's monitor?

 

Thank you!

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 8 of 8

BobbyC.Jones
Advocate
Advocate

@m.vallee I'm so glad you found this useful!

 

@jeremytammik 

The inspiration for this code came from the desire to have buttons on the ribbon that would post the ArchitecturalFloor command with specific floor types active, and then reset the floor types back to the previous setting after the command finished.  It's a simple, and useful, example of the code and I would be happy to put it together if Maxime isn't able to do so with his example.

 

--
Bobby C. Jones
0 Likes