We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How do I create a half circle?

I have the scene shown below. It’s a holder for a cookie cutter. How do I add a half circle 3mm thick?

var scene = new Scene();
var box = new Box();

var tr = scene.RootNode.CreateChildNode(box).Transform;
tr.Scale = new Vector3(60, 3.0, 2.9);
tr.Translation = new Vector3(0.0, -27.0, -3.1);

tr = scene.RootNode.CreateChildNode(box).Transform;
tr.Scale = new Vector3(60, 3.0, 2.9);
tr.Translation = new Vector3(0.0, 27.0, -3.1);

tr = scene.RootNode.CreateChildNode(box).Transform;
tr.Scale = new Vector3(60, 3.0, 9.2);
tr.Translation = new Vector3(0.0, -29.6, 0.0);

tr = scene.RootNode.CreateChildNode(box).Transform;
tr.Scale = new Vector3(60, 3.0, 9.2);
tr.Translation = new Vector3(0.0, 29.6, 0.0);

tr = scene.RootNode.CreateChildNode(box).Transform;
tr.Scale = new Vector3(60, 56.2, 3.0);
tr.Translation = new Vector3(0.0, 0, 3.2);

@ssides0123

 var halfCircle = new Cylinder();
halfCircle.Height = 3;
halfCircle.RadiusBottom = 20;
halfCircle.RadiusTop = 20;
halfCircle.ThetaLength = Math.PI;//half circle
new Scene(halfCircle).Save("D:\\test.obj");

Try this, use a Cylinder with half theta length will generate a circle with thickness.

Thank you so much I was trying NurbsCurve and Shape. Never thought of Cylinder().
But how do I fill it in? I tried GenerateFanCylinder, but that didn’t seem to make any difference. I’m also learning how to rotate it. Not sure what a quaternion is.

var scene = new Scene();
var box = new Box();

var tr = scene.RootNode.CreateChildNode(box).Transform;
tr.Scale = new Vector3(60, 3.0, 2.9);
tr.Translation = new Vector3(0.0, -27.0, -3.1);

tr = scene.RootNode.CreateChildNode(box).Transform;
tr.Scale = new Vector3(60, 3.0, 2.9);
tr.Translation = new Vector3(0.0, 27.0, -3.1);

tr = scene.RootNode.CreateChildNode(box).Transform;
tr.Scale = new Vector3(60, 3.0, 9.2);
tr.Translation = new Vector3(0.0, -29.6, 0.0);

tr = scene.RootNode.CreateChildNode(box).Transform;
tr.Scale = new Vector3(60, 3.0, 9.2);
tr.Translation = new Vector3(0.0, 29.6, 0.0);

tr = scene.RootNode.CreateChildNode(box).Transform;
tr.Scale = new Vector3(60, 56.2, 3.0);
tr.Translation = new Vector3(0.0, 0, 3.2);

var halfCircle = new Cylinder();
halfCircle.Height = 3;
halfCircle.RadiusBottom = 20;
halfCircle.RadiusTop = 20;
halfCircle.ThetaLength = Math.PI;//half circle
halfCircle.GenerateFanCylinder = true;

tr = scene.RootNode.CreateChildNode(halfCircle).Transform;
tr.Translation = new Vector3(0.0, 0.0, 30.0);
// tr.Rotation = new Quaternion(1.0, 1.0, 1.0, 1.0);

scene.Save(_outputPath, FileFormat.STLASCII);

Screenshot 2023-01-05 Half Circle.png (14.6 KB)

@ssides0123

We are checking it and will get back to you shortly.

You can use Transform.EulerAngles to specify the rotation in euler angles(measured in degree), it’s easier than quaternion to understand:

    //There's a bug in exporting non-triangulated meshes in STL exporter,
    //for work-around, you can manually triangulate the cylinder:
    var halfCircleNode = scene.RootNode.CreateChildNode(PolygonModifier.Triangulate(halfCircle.ToMesh()));

    //It's fixed in 23.2, from 23.2 you can just use
    //var halfCircleNode = scene.RootNode.CreateChildNode(halfCircle);

    halfCircleNode.Transform.EulerAngles = new Vector3(90, 0, 0);// rotate 90deg around x axis