Message 1 of 16
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to create a Solid with a single PlanarFace using BRepBuilder.
A PlanarFace Edges based on a curves from sketch of a slab.
Below is the code of how I do it. I get the error "Autodesk.Revit.Exceptions.InvalidOperationException: 'BRep doesn't have enough faces.'" on brepBuilder.Finish();.
I do not understand how to create disconnected Solid with one PlanarFace (highlighted in red in the screenshot).
var brepBuilder = new BRepBuilder(BRepType.Solid);
var surface = BRepBuilderSurfaceGeometry.Create(sketch.SketchPlane.GetPlane(), null);
BRepBuilderGeometryId faceId = brepBuilder.AddFace(surface, false);
foreach (CurveArray ca in sketch.Profile)
{
BRepBuilderGeometryId loopId = brepBuilder.AddLoop(faceId);
foreach (Curve c in ca)
{
var edge = BRepBuilderEdgeGeometry.Create(c);
BRepBuilderGeometryId edgeId = brepBuilder.AddEdge(edge);
brepBuilder.AddCoEdge(loopId, edgeId, false);
}
brepBuilder.FinishLoop(loopId);
}
brepBuilder.FinishFace(faceId);
brepBuilder.Finish();
using (var tr = new Transaction(doc, "Create a DirectShape"))
{
tr.Start();
DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));
ds.SetShape(brepBuilder);
tr.Commit();
}
Solved! Go to Solution.