Create swept geometry along arc

Create swept geometry along arc

Anonymous
Not applicable
2,416 Views
5 Replies
Message 1 of 6

Create swept geometry along arc

Anonymous
Not applicable

I am trying to create a solid which will be a "bent cylinder", as in a tube that follows along an arc.  Here is my attempt:

 

public Solid CreateSolidFromArc(Document doc, Arc arc) {
    const double radius = 0.05;

    XYZ tangent = arc.ComputeDerivatives(0, true).BasisX;
    var plane = Plane.CreateByNormalAndOrigin(tangent, arc.GetEndPoint(0));

    Curve circle0 = Arc.Create(plane, radius, 0, Math.PI);
    Curve circle1 = Arc.Create(plane, radius, Math.PI, Math.PI * 2.0);

    var curveLoop = CurveLoop.Create(new List<Curve> { circle0, circle1 });
    var loops = new List<CurveLoop> { curveLoop };
    var arcCurveLoop = CurveLoop.Create(new List<Curve> {arc});
    return GeometryCreationUtilities.CreateSweptGeometry(arcCurveLoop, 0, 0, loops);
}

 

I get this exception:

Autodesk.Revit.Exceptions.InternalException: createSweptSolid failed when creating the Swept solid.

What am I doing wrong?

0 Likes
Accepted solutions (1)
2,417 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

First, I would suggest that you visualise the curves you are trying to use for debugging purposes before making the call to CreateSweptGeometry, as suggested to Debug Geometric Form Creation:

 

http://thebuildingcoder.typepad.com/blog/2009/07/debug-geometric-form-creation.html

 

Secondly, I have no sample available for CreateSweptGeometry, but maybe this one using CreateSweptBlendGeometry instead is of use as well:

 

http://thebuildingcoder.typepad.com/blog/2018/01/create-swept-blend-in-c.html

 

Cheers,

 

Jeremy



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

Message 3 of 6

Anonymous
Not applicable

Thanks for your answer!

 

In fact, I am creating this swept geometry for the sole purpose of visualizing a `Autodesk.Revit.DB.Arc`.  What I wanted to do is create a circle, sweep it along the arc creating a solid tube, then use the Spatial Field Manager to color the faces.  That way I would be able to see in the UI the Arc.  Is there a better way to do that (without leaving permanent data in the model)?

I don't think `CreateSweptBlendGeometry` is what I'm looking for.

In any case, I think the exception I get is a bug in the Revit API.  The error is basically saying "there's been an internal error" (which being closed-source, I can't debug...).

0 Likes
Message 4 of 6

jeremytammik
Autodesk
Autodesk

My pleasure. Thank you for your appreciation.

 

It does make sense, for transient visualisation, I think.

 

An alternative would be to use a model curve, though non-transient.

 

For an internal exception, please submit a reproducible case that I can pass on to the development team for analysis:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

They should actually never leak out to the end use or add-in, I believe.

 

Thank you!

 

Cheers,

 

Jeremy

 

 



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

0 Likes
Message 5 of 6

RPTHOMAS108
Mentor
Mentor
Accepted solution
return GeometryCreationUtilities.CreateSweptGeometry(arcCurveLoop, 0, arc.GetEndParameter(0), loops);

Try above

 

Message 6 of 6

Anonymous
Not applicable

Awesome!  @RPTHOMAS108, that worked.

 

Thank you both!

0 Likes