Skip to content

[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:

  1. Access the MxCppType instance through MxCpp;
  2. Use members such as' App ',' Properties Window ', and' Ai 'to obtain corresponding function entrances;
  3. Call auxiliary methods such as' newMcGePoint3d 'and' decodeFromGb2312 'to complete common operations.

Example

ts
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

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

ts
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

ts
//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

McDbDatabase


mxcad

get mxcad(): McObject

Return the current active CAD object

Returns

McObject

Methods

decodeFromGb2312

decodeFromGb2312(strHex): string

Convert hex formatted Gb2312 encoding to UTF-8

Parameters

NameTypeDescription
StrHexstringGb2312 encoding

Returns

string

Example

ts
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

NameTypeDescription
StrStringString

Returns

string

Example

ts
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

McDbDatabase


getCurrentMxCAD

getCurrentMxCAD(): McObject

Return the current active CAD object

Returns

McObject


getIdFromCpp

getIdFromCpp(id): any

Obtain the ID of CPP rotation

Parameters

NameType
idstring | number

Returns

any


newMcGePoint3d

newMcGePoint3d(pt?): McGePoint3d

Create a new McGePoint3d instance

Parameters

NameTypeDescription
pt?` AnyPoint coordinates

Returns

McGePoint3d

McGePoint3d instance


newMcGeVector3d

newMcGeVector3d(pt?): McGeVector3d

Create a new McGeVector3d instance

Parameters

NameTypeDescription
pt?` AnyPoint coordinates

Returns

McGeVector3d

McGeVector3d instance