Skip to content
On this page

Creating a Lofted Body

We can create a lofted body by instantiating an Mx3dMkLoft object.

You can use wires to constrain the generated lofted body by adding them to the Mx3dMkLoft object.

typescript
// Get the document
const doc = mxcad3d.getDocument();
// The default constructed right-handed coordinate system is aligned with the world coordinate system
const csysr = new Mx3dGeCSYSR();
// Create a circular geometry with a radius of 10
const circle = new Mx3dGeomCircle(csysr, 10);
// Create a wire for the circle topology
const circleWire_1 = circle.Wire();
// Set the radius of the circle to 15
circle.SetRadius(15);
// Create a new circle by moving the original circle 40 units up and setting the radius to 15
const circleWire_2 = circle.TranslatedByVec(new Mx3dGeVec(0, 0, 40)).Wire();
// Set the radius of the circle to 5
circle.SetRadius(5);
// Create a new circle by moving the previous circle 80 units up and setting the radius to 5
const circleWire_3 = circle.TranslatedByVec(new Mx3dGeVec(0, 0, 80)).Wire();
// Create a new Mx3dMkLoft object
const loft = new Mx3dMkLoft();
// Add the wires to the loft object
loft.AddWire(circleWire_1);
loft.AddWire(circleWire_2);
loft.AddWire(circleWire_3);
// Get the resulting shape from the loft operation
const loftShape = loft.Shape();
// Create a shape label in the document
const loftLabel = doc.addShapeLabel();
// Set the shape for the label
loftLabel.setShape(loftShape);
// Update the display (this will update the model shown in the canvas)
mxcad3d.update();

Note

GitHub and network loading may be slow, please wait a few minutes...