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!
Solved! Go to Solution.
Solved by franciscopossetto. Go to Solution.
Look at the Revit SDK samples, e.g., in
You can also study the examples by The Building Coder:
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:
Check if the lines you used to create the curveloop match those conditions.
I hope it helps.
Kind regards.
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.
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: