Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Simple code crashes Revit

2 REPLIES 2
Reply
Message 1 of 3
Steve_Wellens
348 Views, 2 Replies

Simple code crashes Revit

I'm trying to get code from this sample:  http://thebuildingcoder.typepad.com/blog/2010/05/duplicate-legend-component.html  to run.

 

I am using Revit 2013 so I had to make some changes:

 

ICollection<ElementId> SelectedIds = m_UIDoc.Selection.GetElementIds();
Group group = m_doc.Create.NewGroup(SelectedIds);


Revit died on the NewGroup call.  There was one ElementId in the selection.

 

I put an exception handler around it and got this message:

"External component has thrown an exception."

 

Any ideas? 

Also, is there any other way to clone/copy an Element?

 

Thanks

 

 

Tags (1)
2 REPLIES 2
Message 2 of 3

FYI:  I found the problem was that I was calling the code from a modeless dialog box.  Apparently Revit doesn't like this.

Message 3 of 3
ollikat
in reply to: Steve_Wellens


@Steve_Wellens wrote:

...Apparently Revit doesn't like this.


The Essential question is, what did happen to your main thread of the add-in after the modeless dialog was launched? Because that is the only thread you can call Revit API.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community