Message 1 of 13
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey Everyone, I am trying to get the surfaces between the beams on the bottom of the concrete deck(soffits).
I create a union between the beams and slabs and then iterate though the faces but it only gives me a face count of 13. It should be 16. I tested the same think in dynamo got the geometry, created a union, and then got the surfaces and the count was correct.
Can someone guide me in the right direction on how to get the surfaces I am wanting?
CREATED UNION IN REVIT:
DYNAMO COUNT:
MY CODE:
DirectShape ds = null;
Solid union = null;
foreach (ElementId elemId in selectedIds)
{
Element elem = uidoc.Document.GetElement(elemId);
//get geometry
Options opts = new Options();
GeometryElement geoElem = elem.get_Geometry(opts);
//iterate goemetry elements
foreach (GeometryObject geoObj in geoElem)
{
Solid solid = geoObj as Solid;
if (solid != null && 0 < solid.Faces.Size)
{
if (null == union)
{
union = solid;
}
else
{
union = BooleanOperationsUtils.ExecuteBooleanOperation(union, solid, BooleanOperationsType.Union);
}
}
}
}
using (Transaction tx = new Transaction(doc))
{
tx.Start("Generate Formwork");
//test to make sure you have correct union
ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));
ds.ApplicationId = "Application id";
ds.ApplicationDataId = "Geometry object id";
ds.SetShape(new GeometryObject[] { union });
tx.Commit();
}
//gets the bottom soffits
int faces = 0;
List<PlanarFace> listFaces = new List<PlanarFace>();
if (union != null)
{
foreach (Face face in union.Faces)
{
testing++;
UV pt = new UV(0.5, 0.5);
double faceNormalZ = face.ComputeNormal(pt).Z;
//get slab
if(faceNormalZ == -1)
{
TaskDialog.Show("revit", face.Area.ToString());
}
}
}
}
TaskDialog.Show("Revit", string.Format("{0} surfaces counted", testing));
Solved! Go to Solution.