mxcad API 文档 / McAppType
Class: McAppType
McAppType 类,提供了 MxCAD 的一些基本操作。
Table of contents
Constructors
Properties
Methods
- addNetworkLoadingBigFont
- addNetworkLoadingFont
- addNetworkLoadingTrueTypeFont
- createCloneObject
- destroyObject
- getCurrentMxCAD
- getImp
- getLastCallResult
- getShxBigFonts
- getShxFonts
- getTrueTypeFonts
- getVersionString
- init
- initCalls
- loadFonts
- mcedRGB2Index
- objectIdIsKindOf
- objectIdToObject
- setDefaultTrueTypeFontFile
- setDefaultViewBackgroundColor
- setFontFilePath
Constructors
constructor
• new McAppType()
Properties
MxCADAssist
• MxCADAssist: any
classNameToCreateCalls
• Private
classNameToCreateCalls: any
= {}
imp
• Private
imp: any
内部实现对象
objectIdToObjectCalls
• Private
objectIdToObjectCalls: any
= {}
shxBigFonts
• Private
shxBigFonts: string
[]
shxFonts
• Private
shxFonts: string
[]
trueFonts
• Private
trueFonts: any
Methods
addNetworkLoadingBigFont
▸ addNetworkLoadingBigFont(fontfiles
): void
配置需要通过网络加载的bigfont shx字体
Example
import { MxCpp } from 'mxcad'
MxCpp.App.addNetworkLoadingBigFont(["hztxt.shx", "gbcbig.shx"])
Parameters
Name | Type | Description |
---|---|---|
fontfiles | string | string [] | 加载的字体文件 |
Returns
void
addNetworkLoadingFont
▸ addNetworkLoadingFont(fontfiles
): void
配置需要通过网络加载的shx字体
Example
import { MxCpp } from 'mxcad'
MxCpp.App.addNetworkLoadingFont( ["txt.shx","simplex.shx","aaa.shx","ltypeshp.shx","complex.shx"]);
Parameters
Name | Type | Description |
---|---|---|
fontfiles | string | string [] | 加载的字体文件 |
Returns
void
addNetworkLoadingTrueTypeFont
▸ addNetworkLoadingTrueTypeFont(fontname
, fontzhName
, fontfile
): void
配置需要通过网络加载的Truetype字体
Example
import { MxCpp } from 'mxcad'
MxCpp.App.addNetworkLoadingTrueTypeFont(["simsun","syadobe"],["思原宋体","思原黑体"],["stadobe.otf","syadobe.otf"]);
Parameters
Name | Type | Description |
---|---|---|
fontname | string [] | 字体名 |
fontzhName | string [] | 字体中文名 |
fontfile | string [] | 加载字体文件 |
Returns
void
createCloneObject
▸ createCloneObject(clonobjImp
): null
| McDbObject
创建克隆对象。
Parameters
Name | Type | Description |
---|---|---|
clonobjImp | any | 被克隆的对象。 |
Returns
null
| McDbObject
返回创建的 McDbObject 对象。
destroyObject
▸ destroyObject(pObject
): void
销毁对象。
Parameters
Name | Type | Description |
---|---|---|
pObject | McRxObjectImp | 要销毁的对象。 |
Returns
void
getCurrentMxCAD
▸ getCurrentMxCAD(): McObject
获取当前的 MxDraw 对象。
Example
import { MxCpp } from 'mxcad'
const mxcad = MxCpp.App.getCurrentMxCAD()
Returns
返回当前的 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
}[]
getVersionString
▸ getVersionString(): string
得当前程序的版本信息
Returns
string
init
▸ init(imp
): void
初始化 McAppType 对象。
Parameters
Name | Type | Description |
---|---|---|
imp | any | 传入的 imp 对象。 |
Returns
void
initCalls
▸ Private
initCalls(): void
初始化绘图环境、加载插件、设置绘图参数、创建对象等操作
Returns
void
loadFonts
▸ loadFonts(vecShxFonst
, vecBigShxFonst
, vecTureTypeFonts
, retCall
): void
通知cad程序,将来要使用的字体需要加载,方便后面程序使用.
Parameters
Name | Type | Description |
---|---|---|
vecShxFonst | string [] | shx字体 |
vecBigShxFonst | string [] | bigfont shx字体 |
vecTureTypeFonts | string [] | Truetype字体 ts import { MxCpp } from 'mxcad' MxCpp.App.loadFonts([], [], ["syadobe","simsun"], () => { console.log("加载字体完成"); }); |
retCall | () => void | - |
Returns
void
mcedRGB2Index
▸ mcedRGB2Index(red
, green
, blue
, bAutoNearest?
): number
将 RGB 值转换为索引。
Example
import { MxCpp } from 'mxcad'
const colorIndex = MxCpp.App.mcedRGB2Index(255, 0, 0, bAutoNearest)
Parameters
Name | Type | Default value | Description |
---|---|---|---|
red | number | undefined | 红色值。 |
green | number | undefined | 绿色值。 |
blue | number | undefined | 蓝色值。 |
bAutoNearest | boolean | true | 是否自动获取最近的颜色值。 |
Returns
number
返回转换后的索引值。
objectIdIsKindOf
▸ objectIdIsKindOf(lIdIndex
, className
): boolean
判断一个对象id是否指类类型名对象
Parameters
Name | Type | Description |
---|---|---|
lIdIndex | number | 对象id索引 |
className | string | 对象名称 |
Returns
boolean
objectIdToObject
▸ objectIdToObject(lIdIndex
): null
| McDbObject
将对象 id 转换为 McDbObject 对象。
Parameters
Name | Type | Description |
---|---|---|
lIdIndex | number | 对象的 id。 |
Returns
null
| McDbObject
返回转换后的 McDbObject 对象,如果转换失败,则返回 null。
setDefaultTrueTypeFontFile
▸ setDefaultTrueTypeFontFile(sTrueTypeFontName
): void
配置默认的TrueType字体
Parameters
Name | Type | Description |
---|---|---|
sTrueTypeFontName | string | TrueType字体名 |
Returns
void
setDefaultViewBackgroundColor
▸ setDefaultViewBackgroundColor(red
, green
, blue
): void
设置默认的视区的背景色.
Example
import { MxCpp } from 'mxcad'
MxCpp.App.setDefaultViewBackgroundColor(0, 0, 0)
Parameters
Name | Type | Description |
---|---|---|
red | number | 红色值。 |
green | number | 绿色值。 |
blue | number | 蓝色值。 |
Returns
void
setFontFilePath
▸ setFontFilePath(path
): void
配置字体加载位置,默值是fonts
Parameters
Name | Type | Description |
---|---|---|
path | string | 字体文件路径 |
Returns
void