Call external Command with a ComboBoxEvent

Call external Command with a ComboBoxEvent

SONA-ARCHITECTURE
Advocate Advocate
536 Views
3 Replies
Message 1 of 4

Call external Command with a ComboBoxEvent

SONA-ARCHITECTURE
Advocate
Advocate

Hi.

To create a new pushButton in Revit I use  this command :

PushButtonData _myPushButton = new PushButtonData("Naùe", "Texte", "AssemblyName", "MyClassName");       

And I create my class like this : and implementing IExternalCommand

MyClassName : IExternnalCommand
{
           Public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
           {
                      //do something with commandData...etc. 
                       return Result.Succeeded;
           }
}

Now :

I want to create a ComboBoxData and doing something in Revit when I click on the combo.

So I use one of the 3 events : DropDownOpened

My code is :

void ComboScopBoxOpened(object sender, Autodesk.Revit.UI.Events.ComboBoxDropDownOpenedEventArgs args)
        {
                MyClassName _myClassName = new MyClassName();
                //How to Execute whereas I do not have the commandData informations?
        }

My question is :

How to call my class like a PushButton? How to get the ExternalCommandData?

Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
0 Likes
537 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

In that situation, you are in a modeless context, as far as Revit is concerned.

 

Therefore, you do not have access to a valid Revit API context and you cannot make any calls whatsoever to the Revit API.

 

You cannot create or populate a valid ExternalCommandData, ever.

 

Only Revit can do that.

 

Your only choice here is to implement an external event.

 

This situation is exactly what the external event was designed for.

 

All required information and much more is available in The Building Coder topic group on external events for modeless access and driving Revit from outside:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28

  



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

0 Likes
Message 3 of 4

SONA-ARCHITECTURE
Advocate
Advocate

Hi Jeremy

Thx for answering me.

 

Actually, I create my Ribbon in Visual Studio.

And I'm using the medthod of Joshu Lumley to Invoke functions wich are developped in CSharp in order to debug easly with SharpDevlop and macros.

In VisualStudio, I'd like with the ComboBoxEvent to Invoke my function developpend in SharpDevelopp...

Hope this schema will help you to underestand my problem...screenshot_442.png

Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
0 Likes
Message 4 of 4

jeremytammik
Autodesk
Autodesk

Dear Pierre,

 

If MyClassName implements an external command and the user clicks a button to invoke it, then the commandData argument passed in has been properly created and populated by Revit.

 

As long as that external command is still active, you can pass on that argument and use the data it contains in any other method you like, including ThisApplication.Execute_MyClass.

 

Cheers,

 

Jeremy

 



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

0 Likes