Skip to content
On this page

Creating Extruded Solids

We can create an extruded solid by instantiating an Mx3dMkPrism object.

You can construct an Mx3dMkPrism object by providing a shape to be extruded, such as an Mx3dShapeObject, along with an extrusion vector defined by an Mx3dGeVec object.

typescript
// Get the document
const doc = mxcad3d.getDocument();
// By default, the right-hand coordinate system is aligned with the world coordinate system
const csysr = new Mx3dGeCSYSR();
// Create a geometric ellipse with major and minor radii of 20 and 10
const ellipse = new Mx3dGeomEllipse(csysr, 20, 10);
// Obtain the wire topology of the ellipse
const ellipseWire = ellipse.Wire();
// Extrude the ellipse wire along the vector (0, 0, 50) with a length of 50 units
// The last two arguments indicate whether to copy and normalize complex faces to simple types
const prism = new Mx3dMkPrism(ellipseWire, new Mx3dGeVec(0, 0, 50), false, true);
const prismShape = prism.Shape();
// Create a shape label in the document
const prismLabel = doc.addShapeLabel();
// Set the shape of the label to the extruded shape
prismLabel.setShape(prismShape);
// Update the display (this will update the model displayed in the canvas)
mxcad3d.update();

Note

GitHub and network-related issues might cause slow loading times, requiring a few minutes of waiting...