Partial Torus

Partial Torus

genelibardiDCZT4
Contributor Contributor
396 Views
4 Replies
Message 1 of 5

Partial Torus

genelibardiDCZT4
Contributor
Contributor

Does anyone have a c# method that will take a majorRaduis, minorRadius, and angle and create a solid that is a partial torus that is centered at the 0,0,0 and starts at angle = 0 and goes counter clockwise to "angle"? I have tried and failed using several different methods. Like sweeping a circle around an arc using Solid3d.CreateSweptSolid()

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

ActivistInvestor
Mentor
Mentor

Post your code that isn't working and someone can tell you what's wrong with it. 

 

Also keep in mind that solids created via the API do not have associativity with the objects used to create them. For example, if you created the partial torus using the sweep command, you can edit it using grips on both the path and profile, which isn't possible with solids created via the API. For that reason, some developers avoid using the API and instead create solids by issuing commands.

 

0 Likes
Message 3 of 5

genelibardiDCZT4
Contributor
Contributor

Well, I fixed my own problem. Thanks!

0 Likes
Message 4 of 5

_gile
Consultant
Consultant

Hi,

 

Here's a way using Solid3d.CreateRevolvedSolid:

public static Solid3d CreatePartialTorus(double majorRadius, double minorRadius, double angleOfRotation)
{
    if (majorRadius < minorRadius)
        throw new ArgumentException("Minor radius greater than major radius");

    while (angleOfRotation <= 0)
        angleOfRotation += Math.PI * 2.0;

    using Circle circle = new(new Point3d(majorRadius, 0.0, 0.0), Vector3d.YAxis, minorRadius);
    Solid3d torus = new();
    torus.CreateRevolvedSolid(circle, Point3d.Origin, Vector3d.ZAxis, angleOfRotation, 0.0, new RevolveOptions());
    return torus;
}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 5

genelibardiDCZT4
Contributor
Contributor
Accepted solution

Thank you! That is the solution I used. Cheers.

0 Likes