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: 

Explode Nested Familes

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Dale.Bartlett
2439 Views, 8 Replies

Explode Nested Familes

Dale.Bartlett
Collaborator
Collaborator

This may or may not be considered an API task, but I thought this forum the best place to start. We have been provided with a model where the user has created a single generic family which contains several component families. For example, a bathroom layout with all the fixtures combined into a single generic family (not a group). This generic family needs to be "exploded" so that the nested component families become resident in the host project. It is not possible to copy/paste between family and project. Would anyone care to propose either a manual process or a pseudo code approach? Don't even ask why it was done this way... Dale




______________
Yes, I'm Satoshi.
0 Likes

Explode Nested Familes

This may or may not be considered an API task, but I thought this forum the best place to start. We have been provided with a model where the user has created a single generic family which contains several component families. For example, a bathroom layout with all the fixtures combined into a single generic family (not a group). This generic family needs to be "exploded" so that the nested component families become resident in the host project. It is not possible to copy/paste between family and project. Would anyone care to propose either a manual process or a pseudo code approach? Don't even ask why it was done this way... Dale




______________
Yes, I'm Satoshi.
8 REPLIES 8
Message 2 of 9

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Dale,

 

I suggest these steps:

 

  • Determine the bathroom family instance transform into the project Tb
  • Delete the bathroom instance
  • Open the family definition
  • For each fixture:
  • Determine the fixture family F and its instance transform into the family Tf
  • Insert F into the project using the transform Tf * Tb
  • Repeat for all fixtures

 

Cheers,

 

Jeremy



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

0 Likes

Dear Dale,

 

I suggest these steps:

 

  • Determine the bathroom family instance transform into the project Tb
  • Delete the bathroom instance
  • Open the family definition
  • For each fixture:
  • Determine the fixture family F and its instance transform into the family Tf
  • Insert F into the project using the transform Tf * Tb
  • Repeat for all fixtures

 

Cheers,

 

Jeremy



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

Message 3 of 9
JimJia
in reply to: Dale.Bartlett

JimJia
Alumni
Alumni

Hi Dale,

 

There is no current API meet your requirement.

You need to do it manually as Jeremy mentioned above.

 

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes

Hi Dale,

 

There is no current API meet your requirement.

You need to do it manually as Jeremy mentioned above.

 

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 4 of 9
Anonymous
in reply to: JimJia

Anonymous
Not applicable

With familyinstances based on Level it works. But with families based on faces of other familyinstance or on planes we can not do it.

Any example of how to insert into our project an element based on a face within a family, such as Familyinstance?

0 Likes

With familyinstances based on Level it works. But with families based on faces of other familyinstance or on planes we can not do it.

Any example of how to insert into our project an element based on a face within a family, such as Familyinstance?

Message 5 of 9
jeremytammik
in reply to: JimJia

jeremytammik
Autodesk
Autodesk

As always, I meant those steps to describe an API solution, actually.

 

As always, before programming it, you need to ensure it can be done manually as well.

 

Cheers,

 

Jeremy

 



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

0 Likes

As always, I meant those steps to describe an API solution, actually.

 

As always, before programming it, you need to ensure it can be done manually as well.

 

Cheers,

 

Jeremy

 



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

Message 6 of 9
jeremytammik
in reply to: Anonymous

jeremytammik
Autodesk
Autodesk
0 Likes

Message 7 of 9
Anonymous
in reply to: jeremytammik

Anonymous
Not applicable
Hello Jeremy

I select a Familyinstance (oFi) and with this code I take out all the FamilyInstance sub-elements that it has inside.

But none of them gives me HOST or HOSTFACE, even though if I edit the family, I see that they take it.

How can I check out each Nested Familyinstance and check out HOST and HOSTFACE (if they have)
Do I have to edit the family to get them out, or is there another way?

Dim collector As New FilteredElementCollector(oDoc)
collector = collector.OfClass(GetType(Autodesk.Revit.DB.FamilyInstance)).OfCategory(BuiltInCategory.OST_GenericModel)
'
Dim query As System.Collections.Generic.IEnumerable(Of Autodesk.Revit.DB.FamilyInstance)
query = From element In collector
Where CType(element, FamilyInstance).SuperComponent IsNot Nothing AndAlso CType(element, FamilyInstance).SuperComponent.Id.Equals(oFi.Id)
Select CType(element, FamilyInstance)
'
Dim colFi As List(Of FamilyInstance) = query.ToList
'
Dim mensa As String = "Subfamilias = " & colFi.Count & vbCrLf
For Each oFih As FamilyInstance In colFi
Dim oHo As Element = oFih.Host
Dim oHoF As Reference = oFih.HostFace
mensa &= oFih.Name
If oHo IsNot Nothing Then mensa &= " (" & oHo.Name & ")"
If oHoF IsNot Nothing Then mensa &= " / (" & oDoc.GetElement(oHoF).Name & ")"
mensa &= vbCrLf
Next
MsgBox(mensa)
0 Likes

Hello Jeremy

I select a Familyinstance (oFi) and with this code I take out all the FamilyInstance sub-elements that it has inside.

But none of them gives me HOST or HOSTFACE, even though if I edit the family, I see that they take it.

How can I check out each Nested Familyinstance and check out HOST and HOSTFACE (if they have)
Do I have to edit the family to get them out, or is there another way?

Dim collector As New FilteredElementCollector(oDoc)
collector = collector.OfClass(GetType(Autodesk.Revit.DB.FamilyInstance)).OfCategory(BuiltInCategory.OST_GenericModel)
'
Dim query As System.Collections.Generic.IEnumerable(Of Autodesk.Revit.DB.FamilyInstance)
query = From element In collector
Where CType(element, FamilyInstance).SuperComponent IsNot Nothing AndAlso CType(element, FamilyInstance).SuperComponent.Id.Equals(oFi.Id)
Select CType(element, FamilyInstance)
'
Dim colFi As List(Of FamilyInstance) = query.ToList
'
Dim mensa As String = "Subfamilias = " & colFi.Count & vbCrLf
For Each oFih As FamilyInstance In colFi
Dim oHo As Element = oFih.Host
Dim oHoF As Reference = oFih.HostFace
mensa &= oFih.Name
If oHo IsNot Nothing Then mensa &= " (" & oHo.Name & ")"
If oHoF IsNot Nothing Then mensa &= " / (" & oDoc.GetElement(oHoF).Name & ")"
mensa &= vbCrLf
Next
MsgBox(mensa)
Message 8 of 9
Anonymous
in reply to: jeremytammik

Anonymous
Not applicable

I need to insert into the project each one of the Nested FamilyInstance that contains the family (Supercomponent)


So I need to know the Host and HostFace of each sub Familyinstance to create the SketchPlanes / Levels or similar and insert them into the project.

0 Likes

I need to insert into the project each one of the Nested FamilyInstance that contains the family (Supercomponent)


So I need to know the Host and HostFace of each sub Familyinstance to create the SketchPlanes / Levels or similar and insert them into the project.

Message 9 of 9
LoganAC34
in reply to: Dale.Bartlett

LoganAC34
Advocate
Advocate

Just wanted to share my solution to this - see link below to my post on the Dynamo forum:

https://forum.dynamobim.com/t/how-to-explode-revit-families-similar-to-blocks-in-autocad/17015/4?u=l...

0 Likes

Just wanted to share my solution to this - see link below to my post on the Dynamo forum:

https://forum.dynamobim.com/t/how-to-explode-revit-families-similar-to-blocks-in-autocad/17015/4?u=l...

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

Post to forums  

Autodesk Design & Make Report