Skip to content
On this page

Straight line

We can create a line by instantiating an McDbLine() object. Draw a line by setting the startPoint and endPoint of the McDbLine() instance object, or you can directly use the constructor of McDbLine() to directly set the start point and end point of the line, such as: new McDbLine(x1, y1, z1, x2, y2, z2) can also set a variety of properties such as line color trueColor, linear scale linetypeScale, etc.

In addition, it is possible to draw a line directly through the drawLine() method provided by the mxcad instance object.

Click McDbLine()drawLine() for detailed property and method descriptions.

ts
import { MxCpp, McCmColor, McDbLine, McGePoint3d } from "mxcad"

const mxcad = MxCpp.getCurrentMxCAD()
const line = new McDbLine(0, 0, 0, -80, -80, 0)
line.trueColor = new McCmColor(255, 0, 0)
mxcad.drawEntity(line)

const line_1 = new McDbLine()
let pt1 = new McGePoint3d(100,100,0)
let pt2 = new McGePoint3d(0,0,0)
line_1.startPoint = pt1
line_1.endPoint = pt2
mxcad.drawEntity(line_1)

mxcad.drawLine(pt1.x, pt1.y, pt2.x, pt2.y)