Simple code crashes Revit

Simple code crashes Revit

Anonymous
Not applicable
528 Views
2 Replies
Message 1 of 3

Simple code crashes Revit

Anonymous
Not applicable

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

 

 

0 Likes
529 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

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

0 Likes
Message 3 of 3

ollikat
Collaborator
Collaborator

@Anonymous 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.

0 Likes