Revit crashing when I am writing some code in ComponentManager_UIElementActivate

Revit crashing when I am writing some code in ComponentManager_UIElementActivate

nitinjambhale
Advocate Advocate
471 Views
1 Reply
Message 1 of 2

Revit crashing when I am writing some code in ComponentManager_UIElementActivate

nitinjambhale
Advocate
Advocate

I am trying to start the Revit's Transaction in 

 

private void ComponentManager_UIElementActivated(object sender, Adwin.UIElementActivatedEventArgs e)

{

          Transaction transaction = new Transaction(doc, "Test"))

           transaction.Start("Test");

}

 

But, Revit is crashing when it hit the transaction.Start() method.

I am on Revit API 2020.

 

 

 

0 Likes
Accepted solutions (1)
472 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Nitin,

 

Welcome to Revit API programming!

 

To get started with the Revit API, I suggest that you first of all take a look at the getting started material and work through the step-by-step instructions provided by the DevTV and My First Revit Plugin video tutorials:

 

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

 

That will explain all you need, including the answer to your question.

 

For a quick start, you can also check out the hello world examples in the developer guide:

 

http://help.autodesk.com/view/RVT/2018/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_G...

 

A slightly more complex answer to your question is this:

 

All calls to the Revit API require a valid Revit API context:

 

 

Such a context is not provided by the UIElementActivated.

 

Therefore, you cannot use the Revit API there at all, and consequently not start a transaction either.

 



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

0 Likes