Create simple Solid with CreateRevolvedGeometry

Create simple Solid with CreateRevolvedGeometry

Anonymous
Not applicable
2,100 Views
4 Replies
Message 1 of 5

Create simple Solid with CreateRevolvedGeometry

Anonymous
Not applicable

Hello!

 

I want to create a solid geometry from input curves with CreateRevolvedGeometry method like this:

 

static public Solid ArcSolid(Arc arc)
{
TaskDialog.Show("Arc points:", arc.GetEndPoint(0).ToString() + "|" + arc.GetEndPoint(1).ToString());
Frame frame = new Frame((arc.GetEndPoint(0) - arc.GetEndPoint(0).Z * XYZ.BasisZ), XYZ.BasisX, XYZ.BasisY, XYZ.BasisZ);
Line line2 = Line.CreateBound(arc.GetEndPoint(1), (arc.GetEndPoint(0) - arc.GetEndPoint(0).Z * XYZ.BasisZ));
Line line3 = Line.CreateBound((arc.GetEndPoint(0) - arc.GetEndPoint(0).Z * XYZ.BasisZ), arc.GetEndPoint(0));
CurveLoop cloop = new CurveLoop();
cloop.Append(arc);
cloop.Append(line2);
cloop.Append(line3);
List<CurveLoop> ilcloops = new List<CurveLoop>(1);
ilcloops.Add(cloop);
return GeometryCreationUtilities.CreateRevolvedGeometry(frame, ilcloops, 0, 2 * Math.PI);
}

 

CurveLoop IsOpen=false; HasPlane = true; I attached an image, which contain the output of the taskdialog, a simple drawing, and the exeption. Red arc is the arguments of my "ArcSolid" function. The little spheres demonstrates the 3 points.

 

What is, what i'm not seeing? I can do create with similar function a triangle solid (cone) and a sphere too. 

 

(Sorry for my poor English) Thank you for your help!

 

0 Likes
Accepted solutions (1)
2,101 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni

Look at the Revit SDK samples, e.g., in 

 

  • SDK/Samples/GeometryAPI/GeometryCreation_BooleanOperation/CS/GeometryCreation.cs

 

You can also study the examples by The Building Coder:

 

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 5

franciscopossetto
Advocate
Advocate
Accepted solution

Hey,

 

I would check the CurveLoop. It looks like it is not satisfying some conditions. This is what the documentation says:

 

profileLoopsType: System.Collections.Generic IList CurveLoop
The profile loops to be revolved. No conditions are imposed on the orientations of the loops. This function will use copies of the input loops that have been oriented as necessary to conform to Revit's orientation conventions. Restrictions:

  • The loops must lie in the xz coordinate plane of the input coordinate frame.
  • The curve loop(s) must be closed and must define a single planar domain (one outer loop and, optionally, one or more inner loops).
  • The curve loops must be without intersections, self-intersections, or degeneracies.
  • The loops must lie on the "right" side of the z axis (where x >= 0).
  • No loop may contain just one closed curve - split such loops into two or more curves beforehand.

 

 

Check if the lines you used to create the curveloop match those conditions.

I hope it helps.

 

Kind regards.

Github:
https://github.com/franpossetto
Message 4 of 5

Anonymous
Not applicable

Thank you for the answer both of you!

 

Yay! I made a basis mistake and thought I was on the right way. I didn't notice that my input curve is in the yz plane and not in the xz plane. The conditions: "The loops must lie on the "right" side of the z axis (where x >= 0)" was correct. Anyway, the code was bad too, so i corrected this.

 

static public Solid ArcSolid(Arc arc)
{
Frame frame = new Frame((arc.GetEndPoint(1) - arc.GetEndPoint(1).Z * XYZ.BasisZ), -1 * XYZ.BasisX, -1 * XYZ.BasisY, XYZ.BasisZ);
Line line2 = Line.CreateBound(arc.GetEndPoint(1), (arc.GetEndPoint(1) - arc.GetEndPoint(1).Z * XYZ.BasisZ));
Line line3 = Line.CreateBound((arc.GetEndPoint(1) - arc.GetEndPoint(1).Z * XYZ.BasisZ), arc.GetEndPoint(0));
CurveLoop cloop = new CurveLoop();
cloop.Append(arc);
cloop.Append(line2);
cloop.Append(line3);
List<CurveLoop> ilcloops = new List<CurveLoop>(1);
ilcloops.Add(cloop);
return GeometryCreationUtilities.CreateRevolvedGeometry(frame, ilcloops, 0, 2 * Math.PI);
}

 

I attached the result solid. My project is on 0,1% percent. Thanks again.

Message 5 of 5

jeremy_tammik
Alumni
Alumni

Congratulations on getting it to work and thank you for sharing.

 

After some cleanup, I see the following method:

  

    static public Solid CreateArcSolid( Arc arc )
    {
      XYZ p = arc.GetEndPoint( 0 );
      XYZ q = arc.GetEndPoint( 1 );
      XYZ r = q - q.Z * XYZ.BasisZ;

      Frame frame = new Frame( r, 
        -XYZ.BasisX, -XYZ.BasisY, XYZ.BasisZ );

      Line line2 = Line.CreateBound( q, r );
      Line line3 = Line.CreateBound( r, p );

      CurveLoop loop = new CurveLoop();
      loop.Append( arc );
      loop.Append( line2 );
      loop.Append( line3 );

      List<CurveLoop> loops = new List<CurveLoop>( 1 );
      loops.Add( loop );

      return GeometryCreationUtilities
        .CreateRevolvedGeometry( frame, 
          loops, 0, 2 * Math.PI );
    }

   

That looks as if you are making certain assumptions about the arc.

  

It would be good to know exactly what those assumptions are.

 

By the way, a couple of other basic solids are generated by similar methods in The Building Coder samples module Util.cs:

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/U...

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes