mxcad_2d API 文档 / 2d
Module: 2d
包含用于显示cad图纸的2d相关导出, 所有导出的内容都可以通过mxcad包导入直接使用
Example
import { createMxCad, McCmColor, McDbEntity } from "mxcad"
Table of contents
Namespaces
Enumerations
- ColorIndexType
- ColorMethod
- DxfCode
- FetchAttributes
- McObjectIdType
- MxCADCloneType
- MxCADSelectionSetStatus
- MxPropertiesWindowCustomValueType
Classes
- IMcDbDwgFiler
- McAppType
- McCmColor
- McDbAlignedDimension
- McDbArc
- McDbAttribute
- McDbAttributeDefinition
- McDbBlockReference
- McDbBlockTable
- McDbBlockTableRecord
- McDbCircle
- McDbCurve
- McDbCustomEntity
- McDbDatabase
- McDbDictionary
- McDbDimension
- McDbEllipse
- McDbEntity
- McDbHatch
- McDbLayerTable
- McDbLayerTableRecord
- McDbLine
- McDbLinetypeTable
- McDbLinetypeTableRecord
- McDbMText
- McDbObject
- McDbObjectArray
- McDbPoint
- McDbPolyline
- McDbProxyEntity
- McDbRasterImage
- McDbRasterImageDef
- McDbRotatedDimension
- McDbText
- McDbTextStyleTable
- McDbTextStyleTableRecord
- McDbXrecord
- McGeBound
- McGeDoubleArray
- McGeLongArray
- McGeMatrix3d
- McGePoint3d
- McGePoint3dArray
- McGeStringArray
- McGeVector3d
- McObject
- McObjectId
- McRxObject
- MxCADPluginBase
- MxCADPluginMapDefaultData
- MxCADResbuf
- MxCADSelectionSet
- MxCADUiPrAngle
- MxCADUiPrBase
- MxCADUiPrDist
- MxCADUiPrEntity
- MxCADUiPrInt
- MxCADUiPrKeyWord
- MxCADUiPrPoint
- MxCADUiPrString
- MxCADUtilityClass
- MxCADWorldDraw
- MxCoordConvertType
- MxCppType
- MxPropertiesWindowCustom
- MxPropertiesWindowCustomValue
Interfaces
Type Aliases
Variables
Functions
- MxCheckTheBrowser
- Mx_Erase
- createMcCmColor
- createMxCad
- drawArc
- drawCircle
- drawEllipticalArc
- drawLine
- drawMText
- drawPolyLine
- drawPolygon
- drawRectang
- drawText
- getColorUtils
- getFilterImp
- loadMxCADassembly
- setMcCmColor
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
Name | Type |
---|---|
error | string |
ok | boolean |
var | any |
Mx_Erase
▸ Mx_Erase(): Promise
<void
>
删除对象
Returns
Promise
<void
>
createMcCmColor
▸ createMcCmColor(...ages
): McCmColor
创建颜色对象
Parameters
Name | Type | Description |
---|---|---|
...ages | CreateColorArgs | 颜色参数类型 |
Returns
颜色对象
createMxCad
▸ createMxCad(config?
, mxcadobj?
): Promise
<McObject
>
创建MxCad实例
Example
//通过创建实例实现图纸展示以下基于vite打包工具
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
Name | Type | Description |
---|---|---|
config? | MxCadConfig | 参数配置 |
mxcadobj? | McObject | 对象 |
Returns
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
Name | Type | Description |
---|---|---|
...ages | THREEColorArgs | 颜色参数 |
Returns
Color
THREE.Color
getFilterImp
▸ getFilterImp(filter?
): any
Parameters
Name | Type | Default value |
---|---|---|
filter | null | MxCADResbuf | null |
Returns
any
loadMxCADassembly
▸ loadMxCADassembly(call?
, locateFile?
, wasmBinary?
, fontspath?
, networkFonts?
): Promise
<MxCppType
>
Parameters
Name | Type |
---|---|
call? | (MxCpp : MxCppType ) => void |
locateFile | (fileName : string , base : string | URL ) => string |
wasmBinary? | ArrayBuffer |
fontspath? | string |
networkFonts? | string [] |
Returns
setMcCmColor
▸ setMcCmColor(mcCmColor
, ...ages
): void
设置颜色
Parameters
Name | Type | Description |
---|---|---|
mcCmColor | McCmColor | 颜色对象 |
...ages | CreateColorArgs | 颜色参数类型 |
Returns
void