[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/MxCADWorldDraw
Class: MxCADWorldDraw
2d.MxCADWorldDraw
The drawing context of MxCAD is used to perform graphic rendering and layer settings during the worldDraw phase of custom entities.
Description
This class encapsulates the call entry of the underlying drawing device and provides capabilities such as drawEntity, drawOsnapEntity, set trueColor, set lineWeight, etc, Used for display, snap, and style control of custom graphics in AutoCAD. Common uses include: -Draw solid objects such as polylines, circles, and text; -Set the current color, line type, line width, and layer; -Redraw based on the geometric data of custom entities; -Process the capture and display effects of objects.
Usage:
- Obtain the current drawing context in the worldDraw (draw: MxCADWorldDraw) method of the custom entity;
- Call drawEntity () or drawOsnapEntity () to draw entities;
- Set rendering status through properties such as trueColor, layerId, lineTypeScale, etc;
- Use getData() to retrieve the current database environment when needed.
Summary: MxCADWorldDraw is the core entry point for custom entity rendering, and developers typically use it in WorldDraw to truly display objects in CAD interfaces.
Example
import { McDbCustomEntity, McDbPolyline, McGePoint3d, MxCADWorldDraw } from "mxcad";
class McDbTestLineCustomEntity extends McDbCustomEntity {
private pt1: McGePoint3d = new McGePoint3d();
private pt2: McGePoint3d = new McGePoint3d();
public create(imp?: any): McDbCustomEntity {
return new McDbTestLineCustomEntity(imp);
}
public getTypeName(): string {
return "McDbTestLineCustomEntity";
}
public dwgInFields(filter: any): boolean { return true; }
public dwgOutFields(filter: any): boolean { return true; }
public worldDraw(draw: MxCADWorldDraw): void {
const pl = new McDbPolyline();
pl.addVertexAt(this.pt1);
pl.addVertexAt(this.pt2);
pl.addVertexAt(new McGePoint3d(0, 10, 0));
draw.drawEntity(pl);
}
}Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new MxCADWorldDraw(lPtrWorldDraw)
Constructor function
Parameters
| Name | Type | Description |
|---|---|---|
| LPtrWorldDraw | number | Pass a pointer to the drawing device |
Properties
imp
• imp: any
Internal object implementation
Accessors
layerId
• get layerId(): McObjectId
Returns
• set layerId(val): void
Set or retrieve the currently used layer
Parameters
| Name | Type | Description |
|---|---|---|
| Val | [McObjectid] (2d. McObjectid. md) | Layer ID |
Returns
void
lineTypeId
• get lineTypeId(): McObjectId
Returns
• set lineTypeId(val): void
Set or retrieve the current line type ID being used
Parameters
| Name | Type | Description |
|---|---|---|
| Val | [McObjectid] (2d. McObjectid. md) | Linetype ID |
Returns
void
lineTypeScale
• get lineTypeScale(): number
Returns
number
• set lineTypeScale(val): void
Set or retrieve the current line type scale used
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | Line type ratio |
Returns
void
lineWeight
• get lineWeight(): LineWeight
Returns
• set lineWeight(val): void
Set or retrieve the current line weight being used
Parameters
| Name | Type | Description |
|---|---|---|
| Val | [LineWeight] (../enums/2d. McDb. LineWeight. md) | Used line weight |
Returns
void
trueColor
• get trueColor(): McCmColor
Returns
• set trueColor(val): void
Set or retrieve colors
Parameters
| Name | Type | Description |
|---|---|---|
| Val | [McCMColor] (2d. McCmColor. md) | Color Object (McCMColor) |
Returns
void
Methods
drawEntity
▸ drawEntity(entity): void
Draw instance objects
Parameters
| Name | Type |
|---|---|
entity | McDbEntity |
Returns
void
drawOsnapEntity
▸ drawOsnapEntity(entity): void
Draw an object for capturing and using
Parameters
| Name | Type |
|---|---|
entity | McDbEntity |
Returns
void
getDatabase
▸ getDatabase(): McDbDatabase
Return the database currently being drawn by worddraw.
Returns
getType
▸ getType(): MxCADWorldDrawType
Obtain worddraw type
Returns
initType
▸ initType(type): void
Initialize worddraw type
Parameters
| Name | Type |
|---|---|
type | MxCADWorldDrawType |
Returns
void
setupForEntity
▸ setupForEntity(entity): boolean
Make Draw objects use entity properties
Parameters
| Name | Type |
|---|---|
entity | McDbEntity |
Returns
boolean
