Skip to content
On this page

Path

We can draw paths directly through the path drawing methods provided in mxcad's instance objects, which usually start with path:

  1. Call the pathLineToEx() method to draw a line from the current position to the specified position, specifying the start width, end width, and convexity

  2. Call the pathLineTo() method to draw a line from the current location to the specified location

  3. Call the pathMoveToEx() method to move the path to the specified location, specifying the start width, end width, and convexity

  4. Call the pathMakeExclude() method to exclude the current path, which is mainly used for the drawing of the fill, and dig out the closed area composed of this path in the fill

  5. Call the pathMakeClosed() method to close the path

You can also call the drawPathToPolyline() method to turn a path into a polyline, the drawPathToSpline() method to turn a path into a line, and the drawPathToHatch() method to turn a path into a fill figure.

Click on the path path , drawPath rendering path to check the detailed description attributes and methods.

ts
import { MxCpp } from "mxcad"

const mxcad = MxCpp.getCurrentMxCAD();
// Draw a rectangular box with a path
// Define the start point of a path
mxcad.pathMoveTo(0, 300);
// The next point on the path
mxcad.pathLineTo(100, 300);
// The next point on the path
mxcad.pathLineTo(100, 400);
// The next point on the path
mxcad.pathLineTo(0, 400);
// Set the path to closed
mxcad.pathMakeClosed();
// Generate a rectangle box with a polysemy line
mxcad.drawPathToPolyline();

// Alternatively you can choose to generate a fill path where the parameter is pattern scaling
mxcad.drawPathToHatch(1);

// You can also convert the path to a spline curve
mxcad.drawPathToSpline()