Skip to content
On this page

Text

Text is an indispensable part of the process of editing drawings, it can help explain the author's design intention, with them can make the drawing editing more clear and clear. mxcad provides the ability to draw single and multi-line text, and to set and modify the font, size, Angle, inclination, and other features of the text.

Single line text

We can create single-line text by instantiating a McDbText() object.

Click McDbText() to check the properties and methods in detail.

ts
import { MxCpp, McGePoint3d, McCmColor, McDb, McDbText } from "mxcad"

const mxcad = MxCpp.getCurrentMxCAD()
const text = new McDbText()
text.widthFactor = 1
text.horizontalMode = McDb.TextHorzMode.kTextCenter
text.verticalMode = McDb.TextVertMode.kTextBottom
text.textString = "测试文本"
text.position = text.alignmentPoint = new McGePoint3d(0, 20)
text.trueColor = new McCmColor(255, 0, 255)
text.height = 20
mxcad.drawEntity(text)

Multiple lines of text

We can create a rotating dimensioning class by instantiating a McDbMText() object.

Click McDbMText() to check the properties and methods in detail.

ts
import { MxCpp, McGePoint3d, McCmColor, McDb, McDbMText } from "mxcad"

const mxcad = MxCpp.getCurrentMxCAD()
const text = new McDbMText()
text.attachment = McDb.AttachmentPoint.kTopLeft
text.contents = "第一行文本 \\P 第二行文本"
text.location = new McGePoint3d(0, -20)
text.trueColor = new McCmColor(255, 0, 255)
text.textHeight = 20
mxcad.drawEntity(text)