mxcad_2d API 文档 / 2d / MxCppType
Class: MxCppType
2d.MxCppType
MxCppType 类封装了一系列与 CAD 相关的操作,包括创建点、向量、获取当前对象等
Table of contents
Constructors
Properties
Methods
- decodeFromGb2312
- encodeToGb2312
- getCallResult
- getCurrentDatabase
- getCurrentMxCAD
- newMcGePoint3d
- newMcGeVector3d
Constructors
constructor
• new MxCppType()
Properties
Ai
• Ai: MxAI
Mx AI实例
App
• App: McAppType
McAppType 实例
Example
ts
import { MxCpp } from "mxcad";
const McAppType = MxCpp.App;
PropertiesWindow
• PropertiesWindow: MxPropertiesWindowCustom
PropertiesWindow 属必窗口功能调用实例
Example
ts
import { MxCpp } from "mxcad";
// 属性界面上,对象属性被修改事件。
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 程序集
Example
ts
//获取与修剪相关的信息
import { MxCpp } from "mxcad";
let mxcadTrimAssert = new MxCpp.mxcadassemblyimp.MxDrawTrimAssist()
Methods
decodeFromGb2312
▸ decodeFromGb2312(strHex
): string
把hex格式的Gb2312编码的转成utf8
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);
Parameters
Name | Type | Description |
---|---|---|
strHex | string | Gb2312编码 |
Returns
string
encodeToGb2312
▸ encodeToGb2312(str
): string
把utf8转成hex格式的Gb2312编码
Example
ts
import { MxCpp } from "mxcad";
const stringToEncode = "你好";
const encodedHex = MxCpp.encodeToGb2312(stringToEncode);
console.log("Encoded string to GB2312 hex:", encodedHex);
Parameters
Name | Type | Description |
---|---|---|
str | string | 字符串 |
Returns
string
getCallResult
▸ getCallResult(): number
获取上一次调用的结果
Example
ts
import { MxCpp } from "mxcad";
const res = MxCpp.getCallResult();
console.log(res);
Returns
number
调用结果
getCurrentDatabase
▸ getCurrentDatabase(): McDbDatabase
返回当前活动的CAD对象的数据库对象.
Example
ts
import { MxCpp } from "mxcad";
const dataBase = MxCpp.getCurrentDatabase();
Returns
getCurrentMxCAD
▸ getCurrentMxCAD(): McObject
返回当前活动的CAD对象
Example
ts
import { MxCpp } from "mxcad";
const mxcad = MxCpp.getCurrentMxCAD();
Returns
newMcGePoint3d
▸ newMcGePoint3d(pt?
): McGePoint3d
创建新的 McGePoint3d 实例
Example
ts
import { MxCpp } from "mxcad";
const pt = MxCpp.newMcGePoint3d({x:10,y:10,z:0});
console.log(pt)
Parameters
Name | Type | Description |
---|---|---|
pt? | any | 点坐标 |
Returns
McGePoint3d 实例
newMcGeVector3d
▸ newMcGeVector3d(pt?
): McGeVector3d
创建新的 McGeVector3d 实例
Example
ts
import { MxCpp } from "mxcad";
const vec = MxCpp.newMcGeVector3d({x:10,y:10,z:0});
console.log(vec)
Parameters
Name | Type | Description |
---|---|---|
pt? | any | 点坐标 |
Returns
McGePoint3d 实例