Detecting Revit User Input State in Real-Time via Revit API

Detecting Revit User Input State in Real-Time via Revit API

maxime.touchard7RAK6
Contributor Contributor
997 Views
6 Replies
Message 1 of 7

Detecting Revit User Input State in Real-Time via Revit API

maxime.touchard7RAK6
Contributor
Contributor

Dear Revit API Community,

I am currently working on a project where I need to detect a particular state of Revit: when it is awaiting user input, such as during the creation of a line or a wall. During this state, many buttons on the Revit ribbon are grayed out.

I've explored several ideas within the Revit API to detect this state, but so far, I haven't found a working solution. Here are the approaches I've tried:

  1. DocumentChanged Event: Unfortunately, this event doesn't seem to be triggered when entering or leaving the line/wall drawing mode.

  2. Tick Event of WPF Window with IDockablePaneProvider: While this event seemed promising, I found that it freezes when Revit is in the aforementioned state.

  3. Idling Event: Although this event is typically used to perform background tasks while Revit is idle, it doesn't seem to trigger when Revit is awaiting user input.

Given these challenges, I'm reaching out to the community to see if anyone has encountered a similar requirement or has found a workaround to detect this particular state of Revit in real-time using the Revit API.

Any insights, suggestions, or alternative approaches would be greatly appreciated. Thank you in advance for your assistance.

Best regards

0 Likes
998 Views
6 Replies
Replies (6)
Message 2 of 7

jeremy_tammik
Alumni
Alumni

Pretty tricky, meseems, and nothing official that I can think of. We occasionally discussed checking whether code is currently in a valid Revit API, most recently here:

  

  

Your question is related, but different, I guess. Looking forward to hearing what others think and how you end up solving this.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 7

jeremy_tammik
Alumni
Alumni

Oh, and another very useful-looking contribution that you definitely ought to check out in this context:

   

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 4 of 7

ricaun
Advisor
Advisor

This state of waiting for a user input inside a command I'm not sure if is possible. The state when Revit ribbons are grayed out is like a busy state, if you are the ribbon, Revit is busy doing another thing (waiting for user input or running a command).

 

I don't know what your end goal is. But if you want to grey out your modeless WPF Window when Revit is busy, is possible by using the Idling event and DispatcherTimer.
If the Idling event never trigger in the interval of 1 second, Revit for sure is busy doing something else.

Revit Busy - 2024-03-04 11-32-07.gif

Is not perfect, but it is a start.

 

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 5 of 7

maxime.touchard7RAK6
Contributor
Contributor

Hello @jeremy_tammik and @ricaun 

Thank you for your assistance.

Our objective aligns closely with the solutions you've suggested, with a slight variation. Instead of utilizing modeless windows, we're employing DockablePane. Our functionalities remains accessible at all times, even when Revit is in a "busy" state. Our primary challenge arises when users continuously interact with buttons without comprehending why no action is occurring. This scenario underscores the necessity for a clear indication or notification mechanism to alert users when Revit enters such states, facilitating a smoother user experience.

Warm regards

0 Likes
Message 6 of 7

Speed_CAD
Collaborator
Collaborator

Hi maxime,

 

I don't know if I understood correctly, but do you want to implement something similar to the AutoCAD CommandWillStart event to know when the user starts a Revit command? I had to implement my own CommandWillStart and CommandEnded to add an option to the options bar when the user starts the native command to model beams.

 

Mauricio Jorquera
0 Likes
Message 7 of 7

me16nirmal97
Explorer
Explorer

It seems like you want to prompt the user if there's an open transaction hindering the other add-in executions. I've experienced something similar in Dynamo, where running a script is delayed until an active transaction, like drawing a wall or completing the dimension, is closed. If that's the issue, you might need to retrieve active transaction details and show a prompt requesting user to close that transaction. 

0 Likes