Unable to obtain the GeometryObject of a beam

Unable to obtain the GeometryObject of a beam

Anonymous
Not applicable
737 Views
2 Replies
Message 1 of 3

Unable to obtain the GeometryObject of a beam

Anonymous
Not applicable

I want to obtain the GeometryObject to acquire the outline of a series of beams. After the FamilyInstanceFilter, there are few elements pass the filter, I think its the problem of instruct get_Geometry(opt). How to fix that problem which was not appear when I did the same to columns?

Another question is will the overlap parts of the beams' outline be removed automatically?

See the codes:

 

FamilySymbol beam = doc.GetElement(new ElementId(153240)) as FamilySymbol;
FamilyInstanceFilter familyInstanceFilter = new FamilyInstanceFilter(doc, beam.Id);
FilteredElementCollector filteredElements = new FilteredElementCollector(doc);
filteredElements = filteredElements.WherePasses(familyInstanceFilter);
foreach (FamilyInstance element in filteredElements)
{
if (element != null)
{
TaskDialog.Show("Found", "sa");
Options opt = application.Create.NewGeometryOptions();
opt.ComputeReferences = true;
opt.DetailLevel = ViewDetailLevel.Medium;
//opt.View = doc.ActiveView;
GeometryElement e = element.get_Geometry(opt);
foreach (GeometryObject geoObj in e)
{
//doc.Regenerate();
//TaskDialog.Show("Found", "sa");
GeometryInstance geoInstance = geoObj as GeometryInstance;
GeometryElement geoElement = geoInstance.GetInstanceGeometry();
Transform insTransform = geoInstance.Transform;
foreach (GeometryObject geoObj2 in geoElement)
{
Solid solid2 = geoObj2 as Solid;
if (solid2.Faces.Size > 0)
{
foreach (Edge edge in solid2.Edges)
{
Curve curve = edge.AsCurve();
TaskDialog.Show("revit", edge.AsCurve().GetType().ToString());
}
}
}

}

}

0 Likes
Accepted solutions (1)
738 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk
Accepted solution

First of all:

 

Have you installed RevitLookup?

 

https://github.com/jeremytammik/RevitLookup

 

This invaluable tool enables you to explore the Revit database interactively via the API, including the possibility to snoop through the geometry hierarchy.

 

Secondly:

 

You can always use the SDK sample ElementViewer to see how to access element geometry via the API.

 

If you debug through that twice, selecting once a beam and once a column, you will see what different traversal paths are used to parse the geometry hierarchy.

 

I hope this helps.

 

Cheers,

 

Jeremy



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

Message 3 of 3

Anonymous
Not applicable

Thanks for answering

 

It was the wrong method I have used, I forgot to transform the GeometryElement.

But that answer does help

 

Best wishes

0 Likes