Exception error on brepBuilder.FinishFace() execution

Exception error on brepBuilder.FinishFace() execution

kuribaw
Alumni Alumni
1,297 Views
2 Replies
Message 1 of 3

Exception error on brepBuilder.FinishFace() execution

kuribaw
Alumni
Alumni

Hello,

 

We are facing an exception error when executing brepBuilder.FinishFace()  in our program with Revit API.

 

Any advice and/or suggestions to solve this issue will be appreciated.

 

Please find attached an image file which describes details of the geometry shapes to be generated by this program.

 

Here under inserted the source code.

 

The exception error "Face covers a full period of a periodic coordinate. Parameter name: faceId" happens in the step

when the red line portion in the code is executed. 

 

Thanks and regards,

 

            #region "face6 color=orange"
            curface = "orange";
            {
                // Create CylindricalSurface
                XYZ origin = new XYZ(10.996980, 0.000000, -10.99531);
                XYZ normal = new XYZ(0, -1, 0);
                XYZ xvec = new XYZ(-1, 0, 0);
                XYZ yvec = new XYZ(0, 0, -1);
                double radius = 6;
                Frame basis = new Frame(origin, xvec, yvec, normal);
                CylindricalSurface cylSurf = CylindricalSurface.Create(basis, radius);

                // face
                bool bFaceIsReversed = true;
                BRepBuilderGeometryId faceId = brepBuilder.AddFace(BRepBuilderSurfaceGeometry.Create(cylSurf, null), bFaceIsReversed);
                // set face color as orange
                ElementId materialId = GetColoredMaterialId(255, 159, 0);
                brepBuilder.SetFaceMaterialId(faceId, materialId);
                // Loops
                BRepBuilderGeometryId loopId = brepBuilder.AddLoop(faceId);
                // edge
                {
                    //BRepBuilderEdgeGeometry edge = BRepBuilderEdgeGeometry.Create(new XYZ(11.234278, 300.000000, -5.000000), new XYZ(11.234278, 0.000000, -5.000000));
                    //edgeId_f5_3 = brepBuilder.AddEdge(edge);
                    brepBuilder.AddCoEdge(loopId, edgeId_f5_3, true);
                }
                {
                    XYZ end0 = new XYZ(11.234278, 0.000000, -5.000000);
                    XYZ end1 = new XYZ(5.000000, 0.000000, -11.185635);
                    XYZ pointOnArc = new XYZ(6.770989, 0.000000, -6.736081);
                    Arc arc = Arc.Create(end0, end1, pointOnArc);
                    BRepBuilderEdgeGeometry edge = BRepBuilderEdgeGeometry.Create(arc);
                    edgeId_f6_2 = brepBuilder.AddEdge(edge);
                    brepBuilder.AddCoEdge(loopId, edgeId_f6_2, false);
                }
                {
                    BRepBuilderEdgeGeometry edge = BRepBuilderEdgeGeometry.Create(new XYZ(5.000000, 0.000000, -11.185635), new XYZ(5.000000, 300.000000, -11.185635));
                    edgeId_f6_3 = brepBuilder.AddEdge(edge);
                    brepBuilder.AddCoEdge(loopId, edgeId_f6_3, false);
                }
                {
                    XYZ end0 = new XYZ(5.000000, 300.000000, -11.185635);
                    XYZ end1 = new XYZ(11.234278, 300.000000, -5.000000);
                    XYZ pointOnArc = new XYZ(15.222972, 300.000000, -15.254530);
                    Arc arc = Arc.Create(end0, end1, pointOnArc);
                    BRepBuilderEdgeGeometry edge = BRepBuilderEdgeGeometry.Create(arc);
                    edgeId_f6_4 = brepBuilder.AddEdge(edge);
                    brepBuilder.AddCoEdge(loopId, edgeId_f6_4, false);
                }
                brepBuilder.FinishLoop(loopId);
                brepBuilder.FinishFace(faceId);
            }
            #endregion
0 Likes
Accepted solutions (1)
1,298 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Wataru Kuribayashi,

 

Thank you for your query.

 

The Building Coder recently discussed the use of BrepBuilder to create geometry and thus define a direct shape element:

 

http://thebuildingcoder.typepad.com/blog/2018/02/directshape-from-brepbuilder-and-boolean.html

 

Some important notes from that discussion:

 

> Please note that BRepBuilder wasn’t really meant for 'manually' constructing geometry. Its interface is very cumbersome for that purpose. It was meant for translating existing geometry into Revit, with rather thorough validation of the input geometry.

 

> Note that it’s much easier to use GeometryCreationUtilities functions to create extrusions than it is to use BRepBuilder, unless the whole point of this exercise is to use the latter.

 

> As said, using BRepBuilder to 'manually' construct geometry is very inconvenient and error-prone, and that isn’t its purpose.

 

Therefore, it might be worthwhile for you as well to consider other less complicated and more high-level means to generate the geometry you require.

 

As far as I can tell from the image you attached, the whole solid L shape you require can be generated by one single extrusion, defining the profile curve loop and extruding that along a straight line perpendicular to the profile curve plane:

 geometry_shapes.jpg

 

 

 

I imagine that that would be much simpler than defining each individual subface on its own and then trying to combine them into a valid solid.

 

To create a Solid, you can use one of the GeometryCreationUtilities.CreateExtrusionGeometry method overloads:

 

http://www.revitapidocs.com/2018.1/f72829bc-7108-1e8a-01e1-09c43bc275a9.htm

 

In a family definition, you could use the NewExtrusion and NewExtrusionForm methods:

 

http://www.revitapidocs.com/2018.1/425e8577-ba2a-ba19-ac24-069078f97209.htm

 

http://www.revitapidocs.com/2018.1/4830510f-f19e-f1e2-c1c5-b4eade8f4af2.htm

 

I hope this helps.

 

Best regards,

 

Jeremy



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

Message 3 of 3

kuribaw
Alumni
Alumni

Dear Jeremy,

 

Thank you for your advice.

 

We'll modify the code following your instruction.

 

Best regards,

 

Wataru

0 Likes