Skip to content
On this page

Creating a Cone

We can create a cone by instantiating an Mx3dMkCone object.

You can construct an Mx3dMkCone object by providing a right-handed coordinate system (Mx3dGeCSYSR), the bottom radius, top radius, height, and an optional angle parameter for an incomplete cone.

typescript
// Get the document
const doc = mxcad3d.getDocument();
// By default, the constructed right-handed coordinate system is aligned with the world coordinate system
const csysr = new Mx3dGeCSYSR();
// You can set the location of csysr to the world coordinate (5, 5, 5)
csysr.SetLocation(5, 5, 5);
// Create a cone with bottom radius 15, top radius 5, height 50, and the base center at (5, 5, 5)
const coneMaker = new Mx3dMkCone(csysr, 15, 5, 50);
// Get the topological shape
const coneShape = coneMaker.Shape();
// Create a shape label in the document
const coneLabel = doc.addShapeLabel();
// Add the topological shape to the label
coneLabel.setShape(coneShape);
// Update the display (this will update the model shown in the canvas)
mxcad3d.update();

The constructor of the Mx3dMkCone class also has a fifth optional parameter to create an incomplete cone, similar to a slice cut from a complete cone.

typescript
// The interval [0, Math.PI * 3 / 2] around the Z-axis of csysr forms the incomplete cone
const coneMaker = new Mx3dMkCone(csysr, 15, 5, 50, Math.PI * 3 / 2);

Note

GitHub and network connectivity issues may cause slow loading times, so please be patient.