Nest a FamilyInstance inside another FamilyInstance

Nest a FamilyInstance inside another FamilyInstance

Anonymous
Not applicable
343 Views
3 Replies
Message 1 of 4

Nest a FamilyInstance inside another FamilyInstance

Anonymous
Not applicable

Hello

 

Is there a way to nest a FamilyInstance inside an existing FamilyInstance?

 

I am aware that this blog post describes something similar to what I am talking about but it actually only nests a FamilyInstance inside another when the project is a Family Project and not when its Construction, Architectural, MEP, etc. When you run the example code in an Architectural project, the 2 FamilyInstances are separate and not nested.

 

What I would like to do is take 2 existing FamilyInstance and insert 1 inside the other.

 

My code below attempts to nest a FamilyInstance inside another by adding it as a Sub-Component. The code compiles but it fails at runtime. I believe because SubComponents is deprecated.

 

FamilyInstance a = InsertFamilySymbolFromRfa("C:\\Line_Segment.rfa", doc);
FamilyInstance b = InsertFamilySymbolFromRfa("C:\\Point_Segment_3D.rfa", doc);
a.SubComponents.Insert(b);

 

 

 

0 Likes
344 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

Dear Sam,

 

Yes (for a change).

 

A family instance, e.g. from a family A, can be inserted into a family document, e.g. B.

 

Thus, when you instert an instance of B into a project (or another family) document, you will be creating a nested instance, namely an instance of A within an instance of B.

 

Please learn the standard Revit product usage from a user point of view, then this will be obvious to you, I think.

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 4

Anonymous
Not applicable

Is it not clear I am asking what functions/methods/classes are used to nest a FamilyInstance inside another? Its clear from my thread that my question is 'how do you nest a FamilyInstance using the API' and not 'Is it possible to nest a FamilyInstance'.

 

Replying with a simple 'yes its possible' is redundant and is a display of the logic of child displays when asked a question and not an adult. Note this is a habit you have in almost all of your replies on this forum.

0 Likes
Message 4 of 4

jeremytammik
Autodesk
Autodesk

Dear Sam,

 

I beg your pardon.

 

Thank you for venting your feelings.

 

You can use the NewFamilyInstance method.

 

It works in both family and project documents.

 

Best regards,

 

Jeremy



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

0 Likes