Extract faces from an Extrusion

I am trying to extract faces of an extrusion; however, couldn’t find any solution by myself. Is there any way to get them or should I use sth different than Extrusion?

		// TODO: Assign selection filters for lot
		// ---

		Rhino.Input.Custom.GetObject lotReference = new Rhino.Input.Custom.GetObject();
		lotReference.SetCommandPrompt ("Select a closed planar curve");
		lotReference.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
		lotReference.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve;
		lotReference.GroupSelect = true;
		lotReference.GetMultiple (1, 0);


		// TODO: Create masses
		// ---

		// Creating Empty List of extruded masses
		Rhino.Collections.RhinoList<Extrusion> listOfMasses = new Rhino.Collections.RhinoList<Extrusion> (); 


		// Creating masses and adding them to list
		for (int i = 0; i < lotReference.ObjectCount; i++) {
			double BuildingHeight = randomNumber.Next (BuildingHeightMin, BuildingHeightMax);
			Rhino.Geometry.Extrusion Mass = Rhino.Geometry.Extrusion.Create (lotReference.Object (i).Curve (), BuildingHeight, true);
			//doc.Objects.AddExtrusion (Mass);
			listOfMasses.Add (Mass);
		}

From an extrusion it is not impossible. But if you convert the extrusion to a BRep, you can get access to the Faces:

Extrusion Mass = Extrusion.Create (lotReference.Object (i).Curve (), BuildingHeight, true);
Brep MassBRep = Mass.ToBrep();
foreach(BrepFace face in MassBRep.Faces)
{
  // do stuff
}
1 Like

When I try non rectangular objects, it produces untrimmed surfaces like in the image below. Should I again trim it with curves or may I get the trimmed surface directly?

Hi Caglar,

Use the DuplicateFace method to create breps from your brep faces.
This is python, but you would use the same iteration in C#:

for face in MassBRep.Faces:
    faceBrep = face.DuplicateFace(False)
3 Likes