Skip to content
On this page

mxcad_2d API 文档 / 2d / McDbHatch

Class: McDbHatch

2d.McDbHatch

表示图案填充类,实现实心颜色填充和各种图案填充效果

Example

ts
import { MxCADUiPrPoint, MxCADUtility, McDbHatch, MxCpp, McDb} from "mxcad"
  //选点填充
   const getPoint = new MxCADUiPrPoint();
   console.log("\n指定填充区域内部一点:");
   let pt = (await getPoint.go()) as McGePoint3d;
   if (!pt) return;

   let hatch:McDbHatch = MxCADUtility.builderHatchFromPoint(pt);
   if (!hatch) {
       console.log("没有找到闭合区域\n")
       return;
   }
   // 清除填充图案效果
   hatch.clearPatternDefinition();
   // 添加图案填充定义
   hatch.addPatternDefinition(45, 1, 1, 1, 0.25, [45, 0.17677695, 0, 0, 0.25, 0.125, -0.0625])
   // 设置填充图案
   hatch.setPattern(McDb.HatchPatternType.kCustomDefined, 'test')
   // 设置填充颜色
   hatch.trueColor = new McCmColor(0, 133, 122)
   // 绘制填充对象
   MxCpp.getCurrentMxCAD().drawEntity(hatch);

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new McDbHatch(x?)

构造函数。

Example

ts
import { McDbHatch } from "mxcad";

const hatch = new McDbHatch()

Parameters

NameType
x?object

Overrides

McDbEntity.constructor

Properties

imp

imp: any = 0

内部实现对象。

Inherited from

McDbEntity.imp

Accessors

colorIndex

get colorIndex(): number

得到对象颜色索引

Example

ts
import { McDbEntity, ColorIndexType } from 'mxcad'
 const ent = new McDbEntity();
 ent.colorIndex = ColorIndexType.kByblock;
 console.log(ent.colorIndex)

Returns

number

Inherited from

McDbEntity.colorIndex

set colorIndex(val): void

设置对象颜色索引

Parameters

NameTypeDescription
valnumber颜色索引(ColorIndexType)

Returns

void

Inherited from

McDbEntity.colorIndex


drawOrder

get drawOrder(): number

对象的显示顺序

Example

ts
// 假设ent为有效实例对象
const order = ent.drawOrder();

Returns

number

Inherited from

McDbEntity.drawOrder

set drawOrder(order): void

对象的显示顺序

Example

ts
import { MxCpp, MxCADSelectionSet } from "mxcad";

let ss = new MxCADSelectionSet();
if (!await ss.userSelect("\n选择对象")) return;
//得到当前图上对象的最大,小最显示顺序.
let minmaxOrder = MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder();
// 把对象放到最上面。
let lOrder = minmaxOrder.maxDrawOrder + 1;
ss.forEach((id) => {
  let ent = id.getMcDbEntity();
  if (ent) {
    ent.drawOrder = lOrder;
  }
})

Parameters

NameTypeDescription
ordernumber顺序值

Returns

void

Inherited from

McDbEntity.drawOrder


dxf0

get dxf0(): string

得到对象的DXF组码的类型名,这个和AutoCAD中的DXF组码是一样。 比如直线的类型名为:McDbLine,DXF0组码值: LINE,DXF0组码值可以用来构造集时的类型过滤。

Returns

string

Inherited from

McDbEntity.dxf0


layer

get layer(): string

得到对象图层名

Returns

string

Inherited from

McDbEntity.layer

set layer(val): void

设置对象图层名

Example

ts
import { McDbEntity } from 'mxcad'
 const ent = new McDbEntity();
 ent.layer = "newLayerName";
 console.log(ent.layer)

Parameters

NameTypeDescription
valstring图层名

Returns

void

Inherited from

McDbEntity.layer


layerId

get layerId(): McObjectId

获取图层ID对象

Example

ts
// 假设ent为有效实例对象
const layerId = ent.layerId;

Returns

McObjectId

Inherited from

McDbEntity.layerId

set layerId(id): void

设置图层Id对象

Example

ts
// 假设ent为有效实例对象
const mxcad = MxCpp.getCurrentMxCAD();
const layerId = mxcad.addLayer("测试图层")
ent.layerId = layerId;

Parameters

NameType
idMcObjectId

Returns

void

Inherited from

McDbEntity.layerId


linetype

get linetype(): string

得到对象线型名

Returns

string

Inherited from

McDbEntity.linetype

set linetype(val): void

设置对象线型名

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.linetype = "MyLineType";
console.log(ent.linetype)

Parameters

NameTypeDescription
valstring线型名

Returns

void

Inherited from

McDbEntity.linetype


linetypeId

get linetypeId(): McObjectId

获取实体对象线型ID

Example

ts
// 假设ent为有效实例对象
const linetypeId = ent.linetypeId;

Returns

McObjectId

Inherited from

McDbEntity.linetypeId

set linetypeId(id): void

设置实体对象线型ID

Example

ts
// 假设ent为有效实例对象
const mxcad = MxCpp.getCurrentMxCAD();
const lineId = mxcad.addLinetypeEx("TestMyLine", '25,-5');
ent.linetypeId = lineId;

Parameters

NameType
idMcObjectId

Returns

void

Inherited from

McDbEntity.linetypeId


linetypeScale

get linetypeScale(): number

得到对象线型比例

Returns

number

Inherited from

McDbEntity.linetypeScale

set linetypeScale(val): void

设置对象线型比例

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.linetypeScale = 0.8;
console.log(ent.linetypeScale)

Parameters

NameTypeDescription
valnumber线型比例

Returns

void

Inherited from

McDbEntity.linetypeScale


lineweight

get lineweight(): number

得到对象线重

Returns

number

Inherited from

McDbEntity.lineweight

set lineweight(val): void

设置对象线重

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.lineweight = 20;
console.log(ent.lineweight)

Parameters

NameTypeDescription
valnumber线重

Returns

void

Inherited from

McDbEntity.lineweight


normal

get normal(): McGeVector3d

返回对象的normal

Example

ts

Returns

McGeVector3d

Inherited from

McDbEntity.normal

set normal(val): void

设置对象的normal

Example

ts

Parameters

NameType
valMcGeVector3d

Returns

void

Inherited from

McDbEntity.normal


numLoops

get numLoops(): number

闭合区域次数

Example

ts
// hatch 为图案填充实例对象
const num = hatch.numLoops

Returns

number


numPatternDefinitions

get numPatternDefinitions(): number

图案定义的数量

Example

ts
// hatch 为图案填充实例对象
const num = hatch.numPatternDefinitions;

Returns

number


objectName

get objectName(): string

获取对象名称。

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
console.log(obj.objectName);

Returns

string

返回对象名

Inherited from

McDbEntity.objectName


patternAngle

get patternAngle(): number

获取填充图案角度

Example

ts
// hatch 为图案填充实例对象
const angle = hatch.patternAngle

Returns

number

set patternAngle(angle): void

设置填充图案角度

Example

ts
import { McDbHatch } from "mxcad";

const hatch = new McDbHatch();
hatch.patternAngle(Math.PI/4);

Parameters

NameType
anglenumber

Returns

void


patternDouble

get patternDouble(): boolean

获取填充图案是否是双倍

Example

ts
// hatch 为图案填充实例对象
const isDouble = hatch.patternDouble;
if(isDouble){
  //填充图案为双倍
}else{
  //填充图案不为双倍
}

Returns

boolean

set patternDouble(isDouble): void

设置填充图案是否为双倍

Example

ts
import { McDbHatch } from "mxcad";

const hatch = new McDbHatch();
hatch.patternDouble = true;

Parameters

NameType
isDoubleboolean

Returns

void


patternScale

get patternScale(): number

获取填充图案缩放比例

Example

ts
// hatch 为图案填充实例对象
const scale = hatch.patternScale

Returns

number

set patternScale(scale): void

设置填充图案缩放比例

Example

ts
import { McDbHatch } from "mxcad";

const hatch = new McDbHatch();
hatch.patternScale = 0.8;

Parameters

NameType
scalenumber

Returns

void


patternSpace

get patternSpace(): number

获取填充图案空间

Example

ts
// hatch 为图案填充实例对象
const patternSpace = hatch.patternSpace

Returns

number

set patternSpace(space): void

设置填充图案空间

Example

ts
import { McDbHatch } from "mxcad";

const hatch = new McDbHatch();
hatch.patternSpace = 0.8;

Parameters

NameType
spacenumber

Returns

void


textStyle

get textStyle(): string

得到对象文字样式

Returns

string

Inherited from

McDbEntity.textStyle

set textStyle(val): void

设置对象文字样式

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.textStyle = "st_style";

Parameters

NameTypeDescription
valstring文字样式名

Returns

void

Inherited from

McDbEntity.textStyle


textStyleId

get textStyleId(): McObjectId

获取实体文字样式

Example

ts
// 假设ent为有效实例对象
const textStyleId = ent.textStyleId;

Returns

McObjectId

Inherited from

McDbEntity.textStyleId

set textStyleId(id): void

设置实体的文字样式

Example

ts
// 假设ent为有效实例对象
const mxcad = MxCpp.getCurrentMxCAD();
const textStyleId = mxcad.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);
ent.textStyleId = textStyleId;

Parameters

NameType
idMcObjectId

Returns

void

Inherited from

McDbEntity.textStyleId


trueColor

get trueColor(): McCmColor

得到对象颜色

Example

ts
import { McDbEntity, McCmColor} from 'mxcad'
 const ent = new McDbEntity();
 ent.trueColor = new McCmColor(255, 0, 0);
 console.log(ent.trueColor)

Returns

McCmColor

Inherited from

McDbEntity.trueColor

set trueColor(val): void

设置对象颜色

Parameters

NameType
valMcCmColor

Returns

void

Inherited from

McDbEntity.trueColor


visible

get visible(): boolean

对象是否可见

Returns

boolean

Inherited from

McDbEntity.visible

set visible(val): void

设置是否可见

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.visible = true;
console.log(ent.visible)

Parameters

NameTypeDescription
valboolean布尔值

Returns

void

Inherited from

McDbEntity.visible

Methods

IntersectWith

IntersectWith(intersectObject, exOption): McGePoint3dArray

与其他实体相交, 得到交点

Example

ts
import { McDbLine, McDb } from 'mxcad'
const line1 = new McDbLine(new McGePoint3d(0,0,0), new McGePoint3d(20,1,0));
const line2 = new McDbLine(new McGePoint3d(10,10,0), new McGePoint3d(11,1,0));
const ptArr = line1.IntersectWith(line2, McDb.Intersect.kExtendBoth)

Parameters

NameTypeDescription
intersectObjectMcDbEntity需要相交的是实体对象
exOptionIntersect相交的选项

Returns

McGePoint3dArray

得到所有交点

Inherited from

McDbEntity.IntersectWith


addPatternDefinition

addPatternDefinition(angle, baseX, baseY, offsetX, offsetY, dashes): boolean

添加图案定义

Example

ts
import { McDbHatch } from "mxcad"
const hatch = new McDbHatch()
const res = hatch.addPatternDefinition(45, 0, 0, 0, 0.25, [45, 0.17677695, 0, 0, 0.25, 0.125, -0.0625]);
if(res){
  //添加成功
}else{
  //添加失败
}

Parameters

NameTypeDescription
anglenumber角度 如 45
baseXnumber基点x坐标
baseYnumber基点y坐标
offsetXnumber偏移x坐标
offsetYnumber偏移y坐标
dashesnumber[]短划线数据

Returns

boolean

是否成功添加图案定义


appendCircleLoop

appendCircleLoop(dCenX, dCenY, dR, dPrecision?, loopType?): any

追加圆构造的闭合区域

Example

ts
import { McDbHatch } from "mxcad";
const hatch = new McDbHatch();
const res = hatch.appendCircleLoop(0,0,0,20);
if(res){
   //追加成功
}else{
   //追加失败
}

Parameters

NameTypeDefault valueDescription
dCenXnumberundefined圆心X轴坐标
dCenYnumberundefined圆心Y轴坐标
dRnumberundefined圆半径
dPrecisionnumber0精度参数,默认值为 0。
loopTypenumberMcDb.HatchLoopType.kPolyline循环类型参数,默认值为 McDb.HatchLoopType.kPolyline

Returns

any

追加结果


appendLoop

appendLoop(vertices, bulges?, loopType?): boolean

追加闭合区域

Example

ts
import { McDbHatch, McGePoint3d, McGePoint3dArray } from "mxcad";

  let solid = new McDbHatch();
  const pts = [
  new McGePoint3d({ x: 10, y: 20, z: 0 }),
  new McGePoint3d({ x: 0, y: 0, z: 0 }),
  ];
  const res = solid.appendLoop(new McGePoint3dArray(pts));
  if(res){
     //设置成功
  }else{
     //设置失败
  }

Parameters

NameTypeDefault valueDescription
verticesMcGePoint3dArrayundefined坐标集合
bulgesnumber[][]凸度集合
loopTypenumberMcDb.HatchLoopType.kPolyline闭合区域类型

Returns

boolean

返回追加结果


assertObjectModification

assertObjectModification(autoUndo?): number

设置对象被改变的状态,可自动触发更新显示函数,更新显示。 比如块表记录更新了,需要通知块引用更新显示,可以调用该函数。

Example

ts
//假设obj为一个数据库对象
obj.assertObjectModification()

Parameters

NameTypeDefault value
autoUndobooleanfalse

Returns

number

Inherited from

McDbEntity.assertObjectModification


clearPatternDefinition

clearPatternDefinition(): boolean

清空图案定义

Example

ts
// hatch 为图案填充实例对象
const res = hatch.clearPatternDefinition();
if(res){
  //清空成功
}else{
  //清空失败
}

Returns

boolean


clone

clone(): null | McDbObject

克隆对象。

Example

ts
//假设obj为一个数据库对象
const obj_clone = obj.clone();

Returns

null | McDbObject

克隆出的对象。

Inherited from

McDbEntity.clone


createExtensionDictionary

createExtensionDictionary(): boolean

创建对象的扩展字典数据.

Example

ts
//假设obj为一个数据库对象
const res = obj.createExtensionDictionary();

Returns

boolean

Inherited from

McDbEntity.createExtensionDictionary


deleteXData

deleteXData(appName): boolean

删除实体指定应用程序名称相关的数据

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";

let selEntity = new MxCADUiPrEntity();
selEntity.setMessage("选择对象");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.deleteXData("DataName");
if(res){
  //删除成功
}else
  //删除失败
}

Parameters

NameTypeDescription
appNamestring扩展数据名称

Returns

boolean

Inherited from

McDbEntity.deleteXData


disableDisplay

disableDisplay(isDisable): void

禁用对象的自动更新显示.

Example

ts
import { McDbLine } from 'mxcad'
const line1 = new McDbLine(new McGePoint3d(0,0,0), new McGePoint3d(20,1,0));
line1.disableDisplay(true)

Parameters

NameTypeDescription
isDisableboolean是否禁用对象自动更新显示

Returns

void

Inherited from

McDbEntity.disableDisplay


erase

erase(): boolean

删除对象。

Example

ts
//假设obj为一个数据库对象
const res = obj.erase();
console.log(res);

Returns

boolean

是否删除成功。

Inherited from

McDbEntity.erase


evaluateHatch

evaluateHatch(): boolean

评估填充结果

Example

ts
import { McDbHatch } from "mxcad";

const Hatch hatch = new Hatch();

// 在这里进行填充操作...

// 评估填充结果
const hatchSuccess = HatchEvaluator.EvaluateHatch(hatch);
if (hatchSuccess){
       console.log("\n填充成功!");
   }else{
       console.log("\n填充失败!");
   }

Returns

boolean


explode

explode(): MxCADResbuf

打碎对象,返回打后对象数据链表

Example

ts
import { McDbEntity, MxCADResbuf } from "mxcad";
// 获取目标对象
let getEnt = new MxCADUiPrEntity();
getEnt.setMessage("选择打碎对象:");
let id = await getEnt.go();
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
// 打碎对象
let retExplode: MxCADResbuf = ent.explode();

Returns

MxCADResbuf

resbuf 数据

Inherited from

McDbEntity.explode


getAllAppName

getAllAppName(): McGeStringArray

获取实体中包含的所有 XData 记录的应用程序名(AppName)

Example

ts
// 假设ent为有效实例对象
const appNames = ent.getAllAppName();
console.log(appNames);

Returns

McGeStringArray

Inherited from

McDbEntity.getAllAppName


getArea

getArea(): Object

计算面积

Example

ts
import { McGePoint3d, McDbCircle } from "mxcad"

const center = new McGePoint3d(0,0,0);
const circle = new McDbCircle(center, 20);
const area = circle.getArea();
console.log("圆面积:", area)

Returns

Object

val 面积值 | ret 是否获取成功

NameType
retboolean
valnumber

Inherited from

McDbEntity.getArea


getBoundingBox

getBoundingBox(): Object

得到对象的最小外包

Example

ts
import { McDbText, McGePoint3d } from 'mxcad'
const text = new McDbText();
text.textString = "测试Test";
text.height = 20;
text.position = text.alignmentPoint = new McGePoint3d(0,0,0);
const { minPt, maxPt, ret } = text.getBoundingBox()

Returns

Object

NameType
maxPtMcGePoint3d
minPtMcGePoint3d
retboolean

Inherited from

McDbEntity.getBoundingBox


getDatabase

getDatabase(): McDbDatabase

得到对象所在的数据库

Example

ts
//假设obj为一个数据库对象
const data = obj.getDatabase();

Returns

McDbDatabase

返回数据库

Inherited from

McDbEntity.getDatabase


getDatabaseIndexId

getDatabaseIndexId(): number

获取对象的索引ID

Example

ts
//假设obj为一个数据库对象
const id = obj.getDatabaseIndexId();

Returns

number

Inherited from

McDbEntity.getDatabaseIndexId


getExtensionDictionary

getExtensionDictionary(): McDbDictionary

得到对象的扩展字典数据.

Example

ts
//假设obj为一个数据库对象
const id = obj.getOwnerID();

Returns

McDbDictionary

扩展字典数据

Inherited from

McDbEntity.getExtensionDictionary


getGripPoints

getGripPoints(): McGePoint3dArray

获取对象的控制点

Example

ts
//假设obj为一个数据库对象
const ptArr = obj.getGripPoints();

Returns

McGePoint3dArray

Inherited from

McDbEntity.getGripPoints


getHandle

getHandle(): string

得到对象句柄

Example

ts
//假设obj为一个数据库对象
const handle = obj.getHandle();

Returns

string

返回对象句柄

Inherited from

McDbEntity.getHandle


getImp

getImp(): any

获取内部实现对象。

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
let imp = obj.getImp();

Returns

any

内部实现对象。

Inherited from

McDbEntity.getImp


getJson

getJson(): string

获取 JSON 格式的字符串。

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
const json = obj.getJson()

Returns

string

JSON 格式的字符串。

Inherited from

McDbEntity.getJson


getLoopAt

getLoopAt(loopIndex): Object

获取索引的值

Example

ts
// hatch 为图案填充实例对象
const numLoops = hatch.numLoops;
for (let i = 0; i < numLoops; i++) {
   const loop = hatch.getLoopAt(i);
   console.log(loop)
};

Parameters

NameTypeDescription
loopIndexnumberindex 闭合区域的索引

Returns

Object

ret 是否成功获取 | lootype 类型 | vertices 坐标集合 | bulges凸度集合

NameType
bulgesnumber[]
lootypenumber
retboolean
verticesMcGePoint3d[]

getObjectID

getObjectID(): McObjectId

获取对象 ID。

Example

ts
import { McDbObject } from "mxcad";
const id = obj.getObjectID();

Returns

McObjectId

对象 ID。

Inherited from

McDbEntity.getObjectID


getOwnerID

getOwnerID(): number

得到对象拥用者的id

Example

ts
//假设obj为一个数据库对象
const id = obj.getOwnerID();

Returns

number

Inherited from

McDbEntity.getOwnerID


getPatternDefinitionAt

getPatternDefinitionAt(index): Object

获取对应图案定义的数据

Example

ts
// hatch 为图案填充实例对象
const obj = {};
for (let i = 0; i < obj.numPatternDefinitions; i++) {
obj["patternDefinitions:" + i] = hatch.getPatternDefinitionAt(i);
};

Parameters

NameTypeDescription
indexnumber索引

Returns

Object

ret 是否成功获取 | angle 角度 | baseX, baseY 基点位置 | offsetX, offsetY 偏移位置 | aryDashes 短划线数据

NameType
anglenumber
aryDashesnumber[]
baseXnumber
baseYnumber
offsetXnumber
offsetYnumber
retboolean

getxData

getxData(appName?): MxCADResbuf

得到对象的扩展数据

Example

ts
// 假设ent为有效实例对象
const xData = ent.getXData();

Parameters

NameTypeDefault valueDescription
appNamestring""扩展数据名

Returns

MxCADResbuf

Inherited from

McDbEntity.getxData


getxDataDouble

getxDataDouble(appName): Object

获取实体的指定 XData 类型中的 double 值

Example

ts
// 假设ent为有效实例对象
let data = ent.getxDataDouble("DataName");
if(data.ret){
  console.log(data.val)
}

Parameters

NameTypeDescription
appNamestring扩展数据名称

Returns

Object

double 值

NameType
retboolean
valnumber

Inherited from

McDbEntity.getxDataDouble


getxDataLong

getxDataLong(appName): Object

获取实体的指定 XData 类型中的 long(整数)值

Example

ts
// 假设ent为有效实例对象
let data = ent.getxDataLong("DataName");
if(data.ret){
  console.log(data.val)
}

Parameters

NameTypeDescription
appNamestring扩展数据名称

Returns

Object

long 值

NameType
retboolean
valnumber

Inherited from

McDbEntity.getxDataLong


getxDataPoint

getxDataPoint(appName): Object

获取实体的指定 XData 类型中的点对象

Parameters

NameTypeDescription
appNamestring扩展数据名称

Returns

Object

获取结果及三维点对象

NameType
retboolean
valMcGePoint3d

Inherited from

McDbEntity.getxDataPoint


getxDataString

getxDataString(appName): Object

获取与特定实体关联的 XData 信息,并以字符串形式返回

Example

ts
// 假设ent为有效实例对象
let data = ent.getxDataString("DataName");
if(data.ret){
  console.log(data.val)
}

Parameters

NameTypeDescription
appNamestring扩展数据名称

Returns

Object

val XData信息 | ret 是否返回成功

NameType
retboolean
valstring

Inherited from

McDbEntity.getxDataString


hatchStyle

hatchStyle(): HatchStyle

填充样式

Example

ts
// hatch 为图案填充实例对象
const style = hatch.hatchStyle();

Returns

HatchStyle


highlight

highlight(isHighlight): void

设置对象是否高亮

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.highlight(true);

Parameters

NameTypeDescription
isHighlightboolean是否高亮

Returns

void

Inherited from

McDbEntity.highlight


initTempObject

initTempObject(imp): void

初始化临时对象。

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
obj.initTempObject()

Parameters

NameTypeDescription
impany内部实现对象。

Returns

void

Inherited from

McDbEntity.initTempObject


isErased

isErased(): boolean

对象是否已经删除

Example

ts
//假设obj为一个数据库对象
const res = obj.isErased();
console.log(res);

Returns

boolean

Inherited from

McDbEntity.isErased


isHaveExtensionDictionary

isHaveExtensionDictionary(): boolean

是否有扩展字典数据.

Example

ts
//假设obj为一个数据库对象
const res = obj.isHaveExtensionDictionary();

Returns

boolean

Inherited from

McDbEntity.isHaveExtensionDictionary


isKindOf

isKindOf(sObjectName): boolean

判断对象类型

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
let isKind = obj.isKindOf('SomeObjectType');
console.log(isKind); // 输出: true 或 false

Parameters

NameTypeDescription
sObjectNamestring类型名

Returns

boolean

返回对象是否是目标类型

Inherited from

McDbEntity.isKindOf


isNull

isNull(): any

判断是否为空对象

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
console.log(obj.isNull()); // 输出: true 或 false

Returns

any

Inherited from

McDbEntity.isNull


isSolid

isSolid(): boolean

检查填充对象是否为实体填充

Example

ts
// hatch 为图案填充实例对象
const res = hatch.isSolid();
if(res){
  //实体填充
}else{
  //非实体填充
}

Returns

boolean

布尔值


loopTypeAt

loopTypeAt(loopIndex): number

某次闭合区域索引中的类型

Example

ts
// hatch 为图案填充实例对象
const looptType = hatch.loopTypeAt(0)

Parameters

NameType
loopIndexnumber

Returns

number


mirror

mirror(point1, point2): boolean

镜向对象

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.mirror(new McGePoint3d(0,0,0), new McGePoint3d(20,10,0))

Parameters

NameTypeDescription
point1McGePoint3d镜像基点
point2McGePoint3d-

Returns

boolean

Inherited from

McDbEntity.mirror


move

move(fromPoint, toPoint): boolean

移动对象

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.move(new McGePoint3d(0,0,0), new McGePoint3d(20,0,0))

Parameters

NameTypeDescription
fromPointMcGePoint3d移动开始点
toPointMcGePoint3d移动结束点

Returns

boolean

Inherited from

McDbEntity.move


moveGripPointsAt

moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset): any

移动对象的控制点

Example

ts
//假设obj为一个数据库对象
obj.moveGripPointsAt(1,10,10,10);

Parameters

NameTypeDescription
iIndexnumber索引
dXOffsetnumberX轴偏移量
dYOffsetnumberY轴偏移量
dZOffsetnumberZ轴偏移量

Returns

any

Inherited from

McDbEntity.moveGripPointsAt


patternName

patternName(): string

填充图案名称

Example

ts
// hatch 为图案填充实例对象
const patternName = hatch.patternName()

Returns

string


patternType

patternType(): number

填充图案类型

Example

ts
// hatch 为图案填充实例对象
const type = hatch.patternType()

Returns

number


removeAllLoop

removeAllLoop(): boolean

删除所有闭合区域

Example

ts
// hatch 为图案填充实例对象
const res = hatch.removeAllLoop();
if(res){
  //删除成功
}else{
  //删除失败
}

Returns

boolean


removeLoopAt

removeLoopAt(loopIndex): boolean

删除某个索引下的闭合区域

Example

ts
// hatch 为图案填充实例对象
const res = hatch.removeLoopAt(1);
if(res){
  //删除成功
}else{
  //删除失败
}

Parameters

NameTypeDescription
loopIndexnumber移除的循环的索引

Returns

boolean


rotate

rotate(basePoint, dRotationAngle): boolean

旋转对象

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.rotate(new McGePoint3d(0,0,0), Math.PI)

Parameters

NameTypeDescription
basePointMcGePoint3d旋转基点
dRotationAnglenumber旋转角度

Returns

boolean

Inherited from

McDbEntity.rotate


scaleEntity

scaleEntity(basePoint, dScaleFactor): boolean

缩放对象

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.scaleEntity(new McGePoint3d(0,0,0), 0.5)

Parameters

NameTypeDescription
basePointMcGePoint3d缩放基点
dScaleFactornumber缩放因子(<1 缩小; >1 放大)

Returns

boolean

Inherited from

McDbEntity.scaleEntity


setHatchStyle

setHatchStyle(val): void

设置填充样式

Example

ts
import { McDbHatch, McDb } from "mxcad"

McDbHatch.setHatchStyle(McDb.HatchStyle.kNormal)

Parameters

NameType
valHatchStyle

Returns

void


setJson

setJson(str): boolean

设置 JSON 格式的字符串。

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
const res = obj.setJson('{"key": "value"}');
console.log(res)

Parameters

NameTypeDescription
strstringJSON 格式的字符串。

Returns

boolean

是否设置成功。

Inherited from

McDbEntity.setJson


setLoopAt

setLoopAt(loopIndex, vertices, bulges, loopType?): boolean

设置某个索引下的闭合区域数据

Example

ts
import { McDbHatch } from "mxcad";

const hatch = new McDbHatch();
const pts = [
new McGePoint3d({ x: 10, y: 20, z: 0 }),
new McGePoint3d({ x: 0, y: 0, z: 0 }),
];
const isSuccess = hatch.setLoopAt(0, new McGePoint3dArray(pts), [0.4,0.8]);
if (isSuccess) {
  console.log("循环设置成功!");
} else {
  console.log("循环设置失败...");
}

Parameters

NameTypeDefault valueDescription
loopIndexnumberundefined闭合区域索引
verticesMcGePoint3dArrayundefined坐标集合
bulgesnumber[]undefined凸度集合
loopTypenumberMcDb.HatchLoopType.kPolyline闭合区域类型

Returns

boolean


setPattern

setPattern(type, patName): void

设置填充图案

Example

ts
import { McDbHatch, MxCpp } from "mxcad";

  const hatch = new McDbHatch();
  hatch.setPattern(McDb.HatchPatternType.kCustomDefined, 'test')
  let mxcad = MxCpp.getCurrentMxCAD();
  mxcad.drawEntity(hatch);

Parameters

NameTypeDescription
typenumber填充图案的来源类型
patNamestring填充图案名称

Returns

void


setxData

setxData(xdata): boolean

设置对象的扩展数据

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";

//设置扩展数据
let selEntity = new MxCADUiPrEntity();
selEntity.setMessage("选择对象");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
ent.setxData(new MxCADResbuf([{type:DxfCode.kExDataName,val:"DataName"},{type:DxfCode.kString,val:"yyyyy"}]));

Parameters

NameTypeDescription
xdataMxCADResbuf扩展数据链表

Returns

boolean

Inherited from

McDbEntity.setxData


setxDataDouble

setxDataDouble(appName, val): boolean

设置实体的指定 XData 类型中的 double 值

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
selEntity.setMessage("选择对象");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.setxDataDouble("DataName", 0);
if(res){
  //设置成功
}else{
  //设置失败
}

Parameters

NameTypeDescription
appNamestring扩展数据名称
valnumberdouble 值

Returns

boolean

布尔值

Inherited from

McDbEntity.setxDataDouble


setxDataLong

setxDataLong(appName, val): boolean

设置实体的指定 XData 类型中的 long(整数)值

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";

let selEntity = new MxCADUiPrEntity();
selEntity.setMessage("选择对象");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.setxDataLong("DataName", 123456);
if(res){
  //设置成功
}else{
  //设置失败
}

Parameters

NameTypeDescription
appNamestring扩展数据名称
valnumberlong 值

Returns

boolean

long 值

Inherited from

McDbEntity.setxDataLong


setxDataPoint

setxDataPoint(appName, val): boolean

设置实体的指定 XData 类型中的点对象

Parameters

NameTypeDescription
appNamestring扩展数据名称
valMcGePoint3d点对象

Returns

boolean

获取结果及三维点对象

Inherited from

McDbEntity.setxDataPoint


setxDataString

setxDataString(appName, val): boolean

设置与特定实体关联的 XData 信息,并以字符串形式设置

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
selEntity.setMessage("选择对象");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.setxDataString("DataName", "xxxxx");
if(res){
  //设置成功
}else{
  //设置失败
}

Parameters

NameTypeDescription
appNamestring扩展数据名称
valstring字符串值

Returns

boolean

是否设置成功

Inherited from

McDbEntity.setxDataString


syncData

syncData(_toCpp?): boolean

同步实体的数据。这个方法可能是在修改了实体的属性或者附加了新的数据之后调用的,以确保所有的改变都被正确地保存到实体的数据库记录中。

Example

ts
// 假设ent为有效实例对象
const res = ent.syncData(true);
if(res){
  //同步成功
}else{
  //同步失败
}

Parameters

NameTypeDefault valueDescription
_toCppbooleantrue是否同步数据

Returns

boolean

Inherited from

McDbEntity.syncData


transformBy

transformBy(transformationMatrix): boolean

变换对象

Example

ts
import { McGeMatrix3d, McDbEntity, McGeVector3d} from 'mxcad'
 const ent = new McDbEntity()
   let matrix = new McGeMatrix3d();
   matrix.setToTranslation(new McGeVector3d(20,0,0));//平移
   ent.transformBy(matrix);

Parameters

NameTypeDescription
transformationMatrixMcGeMatrix3d变换矩阵

Returns

boolean

Inherited from

McDbEntity.transformBy


unErase

unErase(): boolean

反删除对象。

Example

ts
//假设obj为一个数据库对象
const res = obj.unErase();
console.log(res);

Returns

boolean

Inherited from

McDbEntity.unErase


updateDisplay

updateDisplay(): void

显示调用对象更新显示.

Example

ts
// 假设ent为有效实例对象
ent.updateDisplay()

Returns

void

Inherited from

McDbEntity.updateDisplay