Skip to content
On this page

mxcad_2d API 文档 / 2d / McAppType

Class: McAppType

2d.McAppType

McAppType 类,提供了 MxCAD 的一些基本操作。

Example

ts
import { MxCpp } from "mxcad";
const McAppType = MxCpp.App

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new McAppType()

Properties

MxCADAssist

MxCADAssist: any

MxCAD辅助

Methods

addNetworkLoadingBigFont

addNetworkLoadingBigFont(fontfiles): void

配置需要通过网络加载的bigfont shx字体

Example

ts
import { MxCpp } from 'mxcad'
MxCpp.App.addNetworkLoadingBigFont(["hztxt.shx", "gbcbig.shx"])

Parameters

NameTypeDescription
fontfilesstring | string[]加载的字体文件

Returns

void


addNetworkLoadingFont

addNetworkLoadingFont(fontfiles): void

配置需要通过网络加载的shx字体

Example

ts
import { MxCpp } from 'mxcad'
MxCpp.App.addNetworkLoadingFont( ["txt.shx","simplex.shx","aaa.shx","ltypeshp.shx","complex.shx"]);

Parameters

NameTypeDescription
fontfilesstring | string[]加载的字体文件

Returns

void


addNetworkLoadingTrueTypeFont

addNetworkLoadingTrueTypeFont(fontname, fontzhName, fontfile): void

配置需要通过网络加载的Truetype字体

Example

ts
import { MxCpp } from 'mxcad'
MxCpp.App.addNetworkLoadingTrueTypeFont(["simsun","syadobe"],["思原宋体","思原黑体"],["stadobe.otf","syadobe.otf"]);

Parameters

NameTypeDescription
fontnamestring[]字体名
fontzhNamestring[]字体中文名
fontfilestring[]加载字体文件

Returns

void


createCloneObject

createCloneObject(clonobjImp): null | McDbObject

创建克隆对象。

Parameters

NameTypeDescription
clonobjImpany被克隆的对象。

Returns

null | McDbObject

返回创建的 McDbObject 对象。


destroyObject

destroyObject(pObject): void

销毁对象。

Parameters

NameTypeDescription
pObjectMcRxObjectImp要销毁的对象。

Returns

void


getCurrentMxCAD

getCurrentMxCAD(): McObject

获取当前的 MxDraw 对象。

Example

ts
import { MxCpp } from 'mxcad'
const mxcad = MxCpp.App.getCurrentMxCAD()

Returns

McObject

返回当前的 McObject 对象。


getImp

getImp(): any

获取 imp 对象。

Returns

any

返回 imp 对象。


getLastCallResult

getLastCallResult(): number

获取最后一次调用的结果。

Returns

number

返回最后一次调用的结果。


getShxBigFonts

getShxBigFonts(): string[]

得到当前支持的所有bigfont shx字体.

Returns

string[]


getShxFonts

getShxFonts(): string[]

得到当前支持的所有shx字体.

Returns

string[]


getTrueTypeFonts

getTrueTypeFonts(): { file: string ; name: string ; zhname: string }[]

得到当前支持的所有TrueType字体.

Returns

{ file: string ; name: string ; zhname: string }[]

name 字体名| zhname 字体中文名 | file 字体文件


getVersionString

getVersionString(): string

得当前程序的版本信息

Returns

string


init

init(imp): void

初始化 McAppType 对象。

Parameters

NameTypeDescription
impany传入的 imp 对象。

Returns

void


loadFonts

loadFonts(vecShxFonst, vecBigShxFonst, vecTureTypeFonts, retCall): void

通知cad程序,将来要使用的字体需要加载,方便后面程序使用.

Example

ts
import { MxCpp } from 'mxcad'
    MxCpp.App.loadFonts([], [], ["syadobe","simsun"], () => {
        console.log("加载字体完成");
    });

Parameters

NameTypeDescription
vecShxFonststring[]shx字体
vecBigShxFonststring[]bigfont shx字体
vecTureTypeFontsstring[]Truetype字体
retCall() => void回调函数

Returns

void


mcedRGB2Index

mcedRGB2Index(red, green, blue, bAutoNearest?): number

将 RGB 值转换为索引。

Example

ts
import { MxCpp } from 'mxcad'
const colorIndex = MxCpp.App.mcedRGB2Index(255, 0, 0, bAutoNearest)

Parameters

NameTypeDefault valueDescription
rednumberundefined红色值。
greennumberundefined绿色值。
bluenumberundefined蓝色值。
bAutoNearestbooleantrue是否自动获取最近的颜色值。

Returns

number

返回转换后的索引值。


objectIdIsKindOf

objectIdIsKindOf(lIdIndex, className): boolean

判断一个对象id是否指类类型名对象

Parameters

NameTypeDescription
lIdIndexnumber对象id索引
classNamestring对象名称

Returns

boolean


objectIdToObject

objectIdToObject(lIdIndex): null | McDbObject

将对象 id 转换为 McDbObject 对象。

Parameters

NameTypeDescription
lIdIndexnumber对象的 id。

Returns

null | McDbObject

返回转换后的 McDbObject 对象,如果转换失败,则返回 null。


setDefaultTrueTypeFontFile

setDefaultTrueTypeFontFile(sTrueTypeFontName): void

配置默认的TrueType字体

Parameters

NameTypeDescription
sTrueTypeFontNamestringTrueType字体名

Returns

void


setDefaultViewBackgroundColor

setDefaultViewBackgroundColor(red, green, blue): void

设置默认的视区的背景色.

Example

ts
import { MxCpp } from 'mxcad'
MxCpp.App.setDefaultViewBackgroundColor(0, 0, 0)

Parameters

NameTypeDescription
rednumber红色值。
greennumber绿色值。
bluenumber蓝色值。

Returns

void


setFontFilePath

setFontFilePath(path): void

配置字体加载位置,默值是fonts

Parameters

NameTypeDescription
pathstring字体文件路径

Returns

void