Hi Arnošt,
See my reactions below:
@arnostlobel wrote:
I want to add a few points here:
First of all, using the idling mechanism is not the way to go in this scenario and I’d like to discourage using it. Please keep in mind that the Idling mechanism was introduced certain and particular patterns mostly around communication between external modeless dialogs and the Revit API. Using Idling outside of this is always tricky and often controversial, plus may be unstable. One think to realize is that Idling means that Revit UI is at rest at the moment. Thus manipulating Revit’s UI (such as adding buttons) goes against that assumption and may lead into unexpected results.
I used the Idling mechanism only to see if I can "enable" my button, but I have removed that code from the Addin (because it didn't change the behaviour)
@arnostlobel wrote:Second, I think Teum_Ham should spend some time investigating why it is that certain buttons on the Architecture tab are disabled. I do not mean his newly added button; I mean other, existing buttons. Teum_Ham stated that “...for example, the "Room" and "Area Boundry" are also being disabled as soon as I select the Architecture tab.” That is suspicious and lead me to think that maybe Teum_Ham has Revit at state at which certain buttons simply need to be disabled. Teum_Ham wondered: “something within Revit is checking if the button should be enabled...” to which I say: Of course! Most menus in Revit are context sensitive and will not have enabled buttons that have no business being enabled at a particular time and context.
This second aspect is what I would start my investigation with. To give more meaningful advice, we need to know what is the state of Revit and the currently active Document in Revit at the time of clicking and switching to the Architectural tab. Is any command already running? Is there even an active document open? (Because if there is not, it would make perfect sense for the Room button to be disabled!)
I understand that certain buttons are unavailable because Revit is "context sensitive". Like the "Room" button is unavailable when there's no room defined in the project.
But to answer your questions:
- No, there is no other command running
- Yes, I have an active document (a project with just two walls)
@arnostlobel wrote:After that is resolved and understood, I’d try to add the button from the regular OnStart call-back, or during ApplicationInitialized event. Those are the two places from which this kind of customization is supposed to be done.
I am using the "PublicFunction OnStartup(application As Autodesk.Revit.UI.UIControlledApplication) As Autodesk.Revit.UI.ResultImplements Autodesk.Revit.UI.IExternalApplication.OnStartup" to create the button on the Architecture ribbon panel.
I also use this function to create my own ribbon with two buttons. These buttons work as expected. But like I said in my previous post, I don't want to create a complete new ribbon for just two buttons.
Do you need any more info?
Thanks!