Get Geometry from Family Symbol

Get Geometry from Family Symbol

Anonymous
Not applicable
3,022 Views
7 Replies
Message 1 of 8

Get Geometry from Family Symbol

Anonymous
Not applicable

Hi Guys,

 

How can I get the geometry from a Family Symbol that is loaded in the document?. 

 

When I check the familiy via the Revit Look Up add-in it seems not to return anything. In addition, whenever I try something like:

 

 

 if (!furniture.IsActive) furniture.Activate();
GeometryElement geoEl = furniture.get_Geometry(m_options);

geoEl is always null

 

Any tips would be great.

 

Nicholas

 

0 Likes
3,023 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk

Maybe your furniture is invisible? What do you have in your options? The call you show will normally not return null.

 



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

0 Likes
Message 3 of 8

Anonymous
Not applicable

Hi Jeremy,

thanks for your reply. Yes, I don't see the furniture in the model, I can only select it in the project browser tab under the generic model category. As for the m_options I set is as:

 

 

 m_options.IncludeNonVisibleObjects = true;

I have run the debugger and and geoEl is always null

 

0 Likes
Message 4 of 8

Moustafa_K
Collaborator
Collaborator

hi,

to get geometry of a family instance, you need to look for geometry instance and not geometry element, try the below code i didn't test it, but i think it will do the job

 

List<GeometryInstance> ginsList = furniture.get_Geometry(m_options).Where(o => o is GeometryInstance).Cast<GeometryInstance>().ToList();

foreach (GeometryInstance gins in ginsList)
{
    foreach (GeometryObject ge in gins.GetInstanceGeometry())
    {
     // your magic here
    }
}

hope that helps

 

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes
Message 5 of 8

jeremytammik
Autodesk
Autodesk

Well, if you do not see the furniture in the model it may not have any geometry. Families can be user defined, and you can define a family that has no geometry. So everything is working as expected, afaict.

 



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

Message 6 of 8

Anonymous
Not applicable

Hi @Moustafa_K ,

 

Your code will thorough a null reference exception, remember that 

 

furniture.get_Geometry(m_options)

is always returning null

0 Likes
Message 7 of 8

Anonymous
Not applicable

Hi @jeremytammik 

 

The family symbol does have geometry

 

Capture.PNG

 

Only when I place a family instance via the NewFamilyInstance() method I am able to see other properties in the properties tab when I select the family, as well having access to the geometry.

 

Capture2.PNG

 

I guess this is only available once the instance is placed in the document?

 

Is there a way to get access to this information beforehand?

 

Thanks

 

Nicholas

0 Likes
Message 8 of 8

FAIR59
Advisor
Advisor

You have to check, if the familysymbol is active. If the symbol is active the geometry is accessible  

FamilySymbol symbol;
if (!symbol.IsActive) symbol.Activate();

Maybe you need a document.regenerate() after . 

 

In the options you can specify the DetailLevel. Try setting the detaillevel to ViewDetailLevel.Fine.