[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/MxCppType
Class: MxCppType
2d.MxCppType
MxCppType is the entry wrapper class for the MxCAD global API.
Description
This class encapsulates the global functionality of MxCAD, including low-level assembly access, current CAD object retrieval, property window interface, AI interface, geometric object creation, and character encoding conversion. It allows plugin developers to access the top-level services of MxCAD through a unified object. Summary of usage:
- Access the MxCppType instance through MxCpp;
- Use members such as' App ',' Properties Window ', and' Ai 'to obtain corresponding function entrances;
- Call auxiliary methods such as' newMcGePoint3d 'and' decodeFromGb2312 'to complete common operations.
Example
import { MxCpp } from "mxcad";
const mxcad = MxCpp.getCurrentMxCAD();
const point = MxCpp.newMcGePoint3d({ x: 100, y: 200, z: 0 });
const decoded = MxCpp.decodeFromGb2312("%c4%e3%ba%c3");
console.log(mxcad, point, decoded);Table of contents
Constructors
Properties
Accessors
Methods
- decodeFromGb2312
- encodeToGb2312
- getCallResult
- getCurrentDatabase
- getCurrentMxCAD
- getIdFromCpp
- newMcGePoint3d
- newMcGeVector3d
Constructors
constructor
• new MxCppType()
Properties
Ai
• Ai: MxAI
Mx AI instance
App
• App: McAppType
McAppType instance
PropertiesWindow
• PropertiesWindow: MxPropertiesWindowCustom
Attributes Window is a mandatory window function calling instance
Example
import { MxCpp } from "mxcad";
//On the property interface, the event of object property being modified.
MxCpp.PropertiesWindow.onEvent_setProperties((id: McObjectId, prop: any) => {
let ent = id.getMcDbEntity();
if (!ent) return;
if (prop.sVarName == "DN") {
ent.setxDataDouble("DN", prop.val);
}
else if (prop.sVarName == "LEN") {
ent.setxDataDouble("LEN", prop.val);
}
});mxcadassemblyimp
• Optional mxcadassemblyimp: any
MxCpp assembly
Example
//Obtain information related to pruning
import { MxCpp } from "mxcad";
let mxcadTrimAssert = new MxCpp.mxcadassemblyimp.MxDrawTrimAssist()Accessors
currentDatabase
• get currentDatabase(): McDbDatabase
Return the database object of the current active CAD object
Returns
mxcad
• get mxcad(): McObject
Return the current active CAD object
Returns
Methods
decodeFromGb2312
▸ decodeFromGb2312(strHex): string
Convert hex formatted Gb2312 encoding to UTF-8
Parameters
| Name | Type | Description |
|---|---|---|
| StrHex | string | Gb2312 encoding |
Returns
string
Example
import { MxCpp } from "mxcad";
const gb2312Hex = "%c4%e3%ba%c3";
const decodedString = MxCpp.decodeFromGb2312(gb2312Hex);
console.log("Decoded string from GB2312 hex:", decodedString);encodeToGb2312
▸ encodeToGb2312(str): string
Convert UTF8 to hex formatted Gb2312 encoding
Parameters
| Name | Type | Description |
|---|---|---|
| Str | String | String |
Returns
string
Example
import { MxCpp } from "mxcad";
Const stringToEncode="Hello";
const encodedHex = MxCpp.encodeToGb2312(stringToEncode);
console.log("Encoded string to GB2312 hex:", encodedHex);getCallResult
▸ getCallResult(): number
Get the result of the last call
Returns
number
Call result
getCurrentDatabase
▸ getCurrentDatabase(): McDbDatabase
Return the database object of the current active CAD object
Returns
getCurrentMxCAD
▸ getCurrentMxCAD(): McObject
Return the current active CAD object
Returns
getIdFromCpp
▸ getIdFromCpp(id): any
Obtain the ID of CPP rotation
Parameters
| Name | Type |
|---|---|
id | string | number |
Returns
any
newMcGePoint3d
▸ newMcGePoint3d(pt?): McGePoint3d
Create a new McGePoint3d instance
Parameters
| Name | Type | Description |
|---|---|---|
pt? | ` Any | Point coordinates |
Returns
McGePoint3d instance
newMcGeVector3d
▸ newMcGeVector3d(pt?): McGeVector3d
Create a new McGeVector3d instance
Parameters
| Name | Type | Description |
|---|---|---|
pt? | ` Any | Point coordinates |
Returns
McGeVector3d instance
