Skip to content
On this page

mxcad_2d API 文档 / 2d

Module: 2d

包含用于显示cad图纸的2d相关导出, 所有导出的内容都可以通过mxcad包导入直接使用

Example

js
import { createMxCad, McCmColor, McDbEntity } from "mxcad"

Table of contents

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

CreateColorArgs

Ƭ CreateColorArgs: THREEColorArgs | [Partial<McCmColorJSON> | McCmColor]

用于指定在创建颜色时可以接受的不同类型的参数形式


McCmColorJSON

Ƭ McCmColorJSON: ExcludePropertiesContainingThisType<McCmColor, Function>

McCmColor的JSON版本


THREEColorArgs

Ƭ THREEColorArgs: [string | number | THREE.Color] | ConstructorArguments<typeof THREE.Color> | []

THREE.Color 构造函数参数类型组成的元组:字符串、数字、THREE.Color

Variables

MxCADUtility

MxCADUtility: MxCADUtilityClass

提供了一系列与绘图相关的工具方法


MxCoordConvert

MxCoordConvert: MxCoordConvertType

提供坐标转换方法


MxCpp

MxCpp: MxCppType

Functions

MxCheckTheBrowser

MxCheckTheBrowser(): Object

Returns

Object

NameType
errorstring
okboolean
varany

Mx_Erase

Mx_Erase(): Promise<void>

删除对象

Returns

Promise<void>


createMcCmColor

createMcCmColor(...ages): McCmColor

创建颜色对象

Parameters

NameTypeDescription
...agesCreateColorArgs颜色参数类型

Returns

McCmColor

颜色对象


createMxCad

createMxCad(config?, mxcadobj?): Promise<McObject>

创建MxCad实例

Example

//通过创建实例实现图纸展示以下基于vite打包工具

ts
createMxCad({
  canvas: "#myCanvas",
  locateFile: (fileName)=> new URL(`/node_modules/mxcad/dist/wasm/2d/${fileName}`, import.meta.url).href,
  fileUrl: new URL("../assets/test.mxweb", import.meta.url).href
})

Parameters

NameTypeDescription
config?MxCadConfig参数配置
mxcadobj?McObject对象

Returns

Promise<McObject>


drawArc

drawArc(): Promise<void>

绘制圆弧

Returns

Promise<void>


drawCircle

drawCircle(): Promise<undefined | McObjectId>

绘圆

Returns

Promise<undefined | McObjectId>


drawEllipticalArc

drawEllipticalArc(): Promise<undefined | McObjectId>

绘制椭圆或椭圆弧

Returns

Promise<undefined | McObjectId>


drawLine

drawLine(): Promise<void>

绘直线

Returns

Promise<void>


drawMText

drawMText(): Promise<undefined | McObjectId>

绘多行文本

Returns

Promise<undefined | McObjectId>


drawPolyLine

drawPolyLine(): Promise<void>

绘多义线

Returns

Promise<void>


drawPolygon

drawPolygon(): Promise<void>

绘制正多边形

Returns

Promise<void>


drawRectang

drawRectang(): Promise<void>

绘制矩形

Returns

Promise<void>


drawText

drawText(): Promise<undefined | McObjectId>

绘制文字

Returns

Promise<undefined | McObjectId>


getColorUtils

getColorUtils(...ages): Color

获取颜色工具

Parameters

NameTypeDescription
...agesTHREEColorArgs颜色参数

Returns

Color

THREE.Color


getFilterImp

getFilterImp(filter?): any

Parameters

NameTypeDefault value
filternull | MxCADResbufnull

Returns

any


loadMxCADassembly

loadMxCADassembly(call?, locateFile?, wasmBinary?, fontspath?, networkFonts?): Promise<MxCppType>

Parameters

NameType
call?(MxCpp: MxCppType) => void
locateFile(fileName: string, base: string | URL) => string
wasmBinary?ArrayBuffer
fontspath?string
networkFonts?string[]

Returns

Promise<MxCppType>


setMcCmColor

setMcCmColor(mcCmColor, ...ages): void

设置颜色

Parameters

NameTypeDescription
mcCmColorMcCmColor颜色对象
...agesCreateColorArgs颜色参数类型

Returns

void