Skip to content
On this page

[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McDbHatch

Class: McDbHatch

2d.McDbHatch

Representing pattern filling classes, achieving solid color filling and various pattern filling effects

Example

ts
import { MxCADUiPrPoint, MxCADUtility, McDbHatch, MxCpp, McDb} from "mxcad"
//Select point filling
   const getPoint = new MxCADUiPrPoint();
Console.log ("\ n Specify a point inside the filled area: ");
   let pt = (await getPoint.go()) as McGePoint3d;
   if (!pt) return;

   let hatch:McDbHatch = MxCADUtility.builderHatchFromPoint(pt);
   if (!hatch) {
Console.log ("Closed area not found \ n")
       return;
   }
//Clear the fill pattern effect
   hatch.clearPatternDefinition();
//Add Pattern Fill Definition
   hatch.addPatternDefinition(45, 1, 1, 1, 0.25, [45, 0.17677695, 0, 0, 0.25, 0.125, -0.0625])
//Set Fill Pattern
   hatch.setPattern(McDb.HatchPatternType.kCustomDefined, 'test')
//Set Fill Color
   hatch.trueColor = new McCmColor(0, 133, 122)
//Draw Fill Object
   MxCpp.getCurrentMxCAD().drawEntity(hatch);

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new McDbHatch(x?)

Constructor.

Parameters

NameType
x?object

Example

ts
import { McDbHatch } from "mxcad";

const hatch = new McDbHatch()

Overrides

McDbEntity.constructor

Properties

imp

imp: any = 0

Internal implementation object.

Inherited from

McDbEntity.imp

Accessors

colorIndex

get colorIndex(): number

Obtain object color index

Returns

number

Example

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

Inherited from

McDbEntity.colorIndex

set colorIndex(val): void

Set object color index

Parameters

NameTypeDescription
ValnumberColorIndexType

Returns

void

Inherited from

McDbEntity.colorIndex


drawOrder

get drawOrder(): number

Display order of objects

Returns

number

Example

ts
//Assuming ent is a valid instance object
const order = ent.drawOrder();

Inherited from

McDbEntity.drawOrder

set drawOrder(order): void

Display order of objects

Parameters

NameTypeDescription
Ordernumbersequential value

Returns

void

Example

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

let ss = new MxCADSelectionSet();
If (! Await ss.userSelect) return;
//Obtain the maximum and minimum display order of objects on the current graph
let minmaxOrder = MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder();
//Place the object at the top.
let lOrder = minmaxOrder.maxDrawOrder + 1;
ss.forEach((id) => {
  let ent = id.getMcDbEntity();
  if (ent) {
    ent.drawOrder = lOrder;
  }
})

Inherited from

McDbEntity.drawOrder


dxf0

get dxf0(): string

Obtain the type name of the object's DXF group code, which is the same as the DXF group code in AutoCAD. For example, the type name of the line is McDbLine, and the group code value for DXF0 is: LINE and DXF0 group code values can be used for type filtering when constructing sets.

Returns

string

Inherited from

McDbEntity.dxf0


layer

get layer(): string

Obtain the layer name of the object

Returns

string

Inherited from

McDbEntity.layer

set layer(val): void

Set object layer name

Parameters

NameTypeDescription
ValstringLayer Name

Returns

void

Example

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

Inherited from

McDbEntity.layer


layerId

get layerId(): McObjectId

Get layer ID object

Returns

McObjectId

Example

ts
//Assuming ent is a valid instance object
const layerId = ent.layerId;

Inherited from

McDbEntity.layerId

set layerId(id): void

Set Layer Id Object

Parameters

NameType
idMcObjectId

Returns

void

Example

ts
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
Const layerId=mxcad. addLayer (Test Layer)
ent.layerId = layerId;

Inherited from

McDbEntity.layerId


linetype

get linetype(): string

Obtain the object line type name

Returns

string

Inherited from

McDbEntity.linetype

set linetype(val): void

Set object line type name

Parameters

NameTypeDescription
ValstringLine type name

Returns

void

Example

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

Inherited from

McDbEntity.linetype


linetypeId

get linetypeId(): McObjectId

Get entity object line type ID

Returns

McObjectId

Example

ts
//Assuming ent is a valid instance object
const linetypeId = ent.linetypeId;

Inherited from

McDbEntity.linetypeId

set linetypeId(id): void

Set entity object line type ID

Parameters

NameType
idMcObjectId

Returns

void

Example

ts
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
const lineId = mxcad.addLinetypeEx("TestMyLine", '25,-5');
ent.linetypeId = lineId;

Inherited from

McDbEntity.linetypeId


linetypeScale

get linetypeScale(): number

Obtain the proportion of object line types

Returns

number

Inherited from

McDbEntity.linetypeScale

set linetypeScale(val): void

Set object line type scale

Parameters

NameTypeDescription
ValnumberLine type ratio

Returns

void

Example

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

Inherited from

McDbEntity.linetypeScale


lineweight

get lineweight(): number

Obtain object line weight

Returns

number

Inherited from

McDbEntity.lineweight

set lineweight(val): void

Set object line weight

Parameters

NameTypeDescription
Valnumberline weight

Returns

void

Example

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

Inherited from

McDbEntity.lineweight


normal

get normal(): McGeVector3d

Return the normal of the object

Returns

McGeVector3d

Example

ts

Inherited from

McDbEntity.normal

set normal(val): void

Set the normal of the object

Parameters

NameType
valMcGeVector3d

Returns

void

Example

ts

Inherited from

McDbEntity.normal


numLoops

get numLoops(): number

Number of closed areas

Returns

number

Example

ts
//Hatch is an instance object for pattern filling
const num = hatch.numLoops

numPatternDefinitions

get numPatternDefinitions(): number

The number of pattern definitions

Returns

number

Example

ts
//Hatch is an instance object for pattern filling
const num = hatch.numPatternDefinitions;

objectName

get objectName(): string

Get the object name.

Returns

string

Return object name

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbEntity.objectName


patternAngle

get patternAngle(): number

Obtain the angle of the fill pattern

Returns

number

Example

ts
//Hatch is an instance object for pattern filling
const angle = hatch.patternAngle

set patternAngle(angle): void

Set the angle of the fill pattern

Parameters

NameType
anglenumber

Returns

void

Example

ts
import { McDbHatch } from "mxcad";

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

patternDouble

get patternDouble(): boolean

Obtain whether the fill pattern is double

Returns

boolean

Example

ts
//Hatch is an instance object for pattern filling
const isDouble = hatch.patternDouble;
if(isDouble){
//Double the filling pattern
}else{
//The filling pattern is not double
}

set patternDouble(isDouble): void

Set the fill pattern to double

Parameters

NameType
isDoubleboolean

Returns

void

Example

ts
import { McDbHatch } from "mxcad";

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

patternScale

get patternScale(): number

Get the scaling ratio of the fill pattern

Returns

number

Example

ts
//Hatch is an instance object for pattern filling
const scale = hatch.patternScale

set patternScale(scale): void

Set the scaling ratio of the fill pattern

Parameters

NameType
scalenumber

Returns

void

Example

ts
import { McDbHatch } from "mxcad";

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

patternSpace

get patternSpace(): number

Obtain the space for filling patterns

Returns

number

Example

ts
//Hatch is an instance object for pattern filling
const patternSpace = hatch.patternSpace

set patternSpace(space): void

Set the space for filling patterns

Parameters

NameType
spacenumber

Returns

void

Example

ts
import { McDbHatch } from "mxcad";

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

textStyle

get textStyle(): string

Obtain the text style of the object

Returns

string

Inherited from

McDbEntity.textStyle

set textStyle(val): void

Set object text style

Parameters

NameTypeDescription
ValstringText style name

Returns

void

Example

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

Inherited from

McDbEntity.textStyle


textStyleId

get textStyleId(): McObjectId

Get entity text style

Returns

McObjectId

Example

ts
//Assuming ent is a valid instance object
const textStyleId = ent.textStyleId;

Inherited from

McDbEntity.textStyleId

set textStyleId(id): void

Set the text style of the entity

Parameters

NameType
idMcObjectId

Returns

void

Example

ts
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
const textStyleId = mxcad.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);
ent.textStyleId = textStyleId;

Inherited from

McDbEntity.textStyleId


trueColor

get trueColor(): McCmColor

Obtain the color of the object

Returns

McCmColor

Example

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

Inherited from

McDbEntity.trueColor

set trueColor(val): void

Set object color

Parameters

NameType
valMcCmColor

Returns

void

Inherited from

McDbEntity.trueColor


visible

get visible(): boolean

Is the object visible

Returns

boolean

Inherited from

McDbEntity.visible

set visible(val): void

Set whether it is visible

Parameters

NameTypeDescription
ValbooleanBoolean value

Returns

void

Example

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

Inherited from

McDbEntity.visible

Methods

IntersectWith

IntersectWith(intersectObject, exOption): McGePoint3dArray

Intersection with other entities to obtain the intersection point

Parameters

NameTypeDescription
IntersectObject[McDbEntity] (2d. McDbEntity. md)The entity object that needs to intersect is the entity object
ExOptionIntersection (../enums/2d. McDb. Intersect. md)Intersection options

Returns

McGePoint3dArray

Obtain all intersection points

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)

Inherited from

McDbEntity.IntersectWith


addPatternDefinition

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

Add pattern definition

Parameters

NameTypeDescription
Anglenumberangle such as 45
BaseXnumberBase point x coordinate
BaseYnumberbase point y coordinate
Offset Xnumberoffset x coordinate
Offset Ynumberoffset y coordinate
Dashesnumber []dash data

Returns

boolean

Did you successfully add the pattern definition

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){
//Added successfully
}else{
//Add failed
}

appendCircleLoop

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

Add a closed area for circle construction

Parameters

NameTypeDefault valueDescription
DCenXnumberundefinedX-axis coordinate of the center of the circle
DCenYnumberundefinedY-axis coordinate of the center of the circle
DRnumberundefinedradius of circle
DPrecisionnumber0Precision parameter, default value is 0
loopTypenumberMcDb. HatchLoopType. kPolyline Loop type parameter, default value is McDb HatchLoopType.kPolyline

Returns

any

Additional Results

Example

ts
import { McDbHatch } from "mxcad";
const hatch = new McDbHatch();
const res = hatch.appendCircleLoop(0,0,0,20);
if(res){
//Added successfully
}else{
//Addition failed
}

appendLoop

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

Add closed area

Parameters

NameTypeDefault valueDescription
Vertices[McGePoint3dArray] (2d. McGePoint3dArray. md)undefinedCoordinate set
Bulgesnumber []convexity set
loopTypenumber`McDb. HatchLoopType.kPolylineClosed Area Type

Returns

boolean

Return additional results

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){
//Setting successful
  }else{
//Setting failed
  }

assertObjectModification

assertObjectModification(autoUndo?): number

Setting the state of the object to be changed can automatically trigger the update display function to update the display. For example, if the block table record is updated and the block reference needs to be notified to update the display, this function can be called.

Parameters

NameTypeDefault value
autoUndobooleanfalse

Returns

number

Example

ts
//Assuming obj is a database object
obj.assertObjectModification()

Inherited from

McDbEntity.assertObjectModification


clearPatternDefinition

clearPatternDefinition(): boolean

Clear pattern definition

Returns

boolean

Example

ts
//Hatch is an instance object for pattern filling
const res = hatch.clearPatternDefinition();
if(res){
//Cleared successfully
}else{
//Clearing failed
}

clone

clone(): null | McDbObject

Clone objects.

Returns

null | McDbObject

The cloned object.

Example

ts
//Assuming obj is a database object
const obj_clone = obj.clone();

Inherited from

McDbEntity.clone


createExtensionDictionary

createExtensionDictionary(): boolean

Create extended dictionary data for objects

Returns

boolean

Example

ts
//Assuming obj is a database object
const res = obj.createExtensionDictionary();

Inherited from

McDbEntity.createExtensionDictionary


deleteXData

deleteXData(appName): boolean

Delete data related to entity specified application name

Parameters

NameTypeDescription
AppNamestringExtended Data Name

Returns

boolean

Example

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

let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
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){
//Delete successfully
}else
//Delete failed
}

Inherited from

McDbEntity.deleteXData


disableDisplay

disableDisplay(isDisable): void

Disable automatic update display of objects

Parameters

NameTypeDescription
IsDisablebooleanDo you want to disable automatic object update display

Returns

void

Example

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

Inherited from

McDbEntity.disableDisplay


erase

erase(): boolean

Delete object.

Returns

boolean

Whether the deletion was successful.

Example

ts
//Assuming obj is a database object
const res = obj.erase();
console.log(res);

Inherited from

McDbEntity.erase


explode

explode(): MxCADResbuf

Break the object and return the linked list of the object's data after being broken

Returns

MxCADResbuf

Rebuf data

Example

ts
import { McDbEntity, MxCADResbuf } from "mxcad";
//Obtain the target object
let getEnt = new MxCADUiPrEntity();
GetEnt.setMessage ("Select object to break: ");
let id = await getEnt.go();
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
//Smash objects
      let retExplode: MxCADResbuf = ent.explode();
      if (retExplode.GetCount() == 0) return;
      let iExplodeConut = retExplode.GetCount();
      for (let j = 0; j < iExplodeConut; j++) {
          let tmpobj = retExplode.AtObject(j).val;
          if(tmpobj instanceof McDbEntity ){
              mxcad.drawEntity(tmpobj);
          }
      }

Inherited from

McDbEntity.explode


getAllAppName

getAllAppName(): McGeStringArray

Get the application name (AppName) of all XData records contained in the entity

Returns

McGeStringArray

Example

ts
//Assuming ent is a valid instance object
const appNames = ent.getAllAppName();
console.log(appNames);

Inherited from

McDbEntity.getAllAppName


getArea

getArea(): Object

Calculate Area

Returns

Object

Is the val area value | ret successfully obtained

NameType
retboolean
valnumber

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 ("Circle area: ", area)

Inherited from

McDbEntity.getArea


getBoundingBox

getBoundingBox(): Object

Obtain the minimum outsourcing of the object

Returns

Object

NameType
maxPtMcGePoint3d
minPtMcGePoint3d
retboolean

Example

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

Inherited from

McDbEntity.getBoundingBox


getDatabase

getDatabase(): McDbDatabase

Get the database where the object is located

Returns

McDbDatabase

Return to database

Example

ts
//Assuming obj is a database object
const data = obj.getDatabase();

Inherited from

McDbEntity.getDatabase


getDatabaseIndexId

getDatabaseIndexId(): number

Get the index ID of the object

Returns

number

Example

ts
//Assuming obj is a database object
const id = obj.getDatabaseIndexId();

Inherited from

McDbEntity.getDatabaseIndexId


getExtensionDictionary

getExtensionDictionary(): McDbDictionary

Obtain the extended dictionary data of the object

Returns

McDbDictionary

Expand dictionary data

Example

ts
//Assuming obj is a database object
const id = obj.getOwnerID();

Inherited from

McDbEntity.getExtensionDictionary


getGripPoints

getGripPoints(): McGePoint3dArray

Get the control points of the object

Returns

McGePoint3dArray

Example

ts
//Assuming obj is a database object
const ptArr = obj.getGripPoints();

Inherited from

McDbEntity.getGripPoints


getHandle

getHandle(): string

Obtain object handle

Returns

string

Return object handle

Example

ts
//Assuming obj is a database object
const handle = obj.getHandle();

Inherited from

McDbEntity.getHandle


getImp

getImp(): any

Retrieve internal implementation objects.

Returns

any

Internal implementation object.

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbEntity.getImp


getJson

getJson(): string

Retrieve a string in JSON format.

Returns

string

A string in JSON format.

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbEntity.getJson


getLoopAt

getLoopAt(loopIndex): Object

Retrieve the value of the index

Parameters

NameTypeDescription
LoopIndexnumberindex of closed area

Returns

Object

Whether ret successfully obtained | lootype type | verticals coordinate set | bulges convexity set

NameType
bulgesnumber[]
lootypenumber
retboolean
verticesMcGePoint3d[]

Example

ts
//Hatch is an instance object for pattern filling
const numLoops = hatch.numLoops;
for (let i = 0; i < numLoops; i++) {
   const loop = hatch.getLoopAt(i);
   console.log(loop)
};

getObjectID

getObjectID(): McObjectId

Get the object ID.

Returns

McObjectId

Object ID.

Example

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

Inherited from

McDbEntity.getObjectID


getOwnerID

getOwnerID(): number

Obtain the ID of the object owner

Returns

number

Example

ts
//Assuming obj is a database object
const id = obj.getOwnerID();

Inherited from

McDbEntity.getOwnerID


getPatternDefinitionAt

getPatternDefinitionAt(index): Object

Obtain data corresponding to the pattern definition

Parameters

NameTypeDescription
Indexnumberindex

Returns

Object

Whether ret successfully obtained | angle | baseX, BaseY base point position | offsetX, OffsetY offset position | aryDashes dash data

NameType
anglenumber
aryDashesnumber[]
baseXnumber
baseYnumber
offsetXnumber
offsetYnumber
retboolean

Example

ts
//Hatch is an instance object for pattern filling
const obj = {};
for (let i = 0; i < obj.numPatternDefinitions; i++) {
obj["patternDefinitions:" + i] = hatch.getPatternDefinitionAt(i);
};

getxData

getxData(appName?): MxCADResbuf

Obtain the extended data of the object

Parameters

NameTypeDefault valueDescription
AppNamestring""Extended Data Name

Returns

MxCADResbuf

Example

ts
//Assuming ent is a valid instance object
const xData = ent.getXData();

Inherited from

McDbEntity.getxData


getxDataDouble

getxDataDouble(appName): Object

Retrieve the double value from the specified XData type of the entity

Parameters

NameTypeDescription
AppNamestringExtended Data Name

Returns

Object

Double value

NameType
retboolean
valnumber

Example

ts
//Assuming ent is a valid instance object
let data = ent.getxDataDouble("DataName");
if(data.ret){
  console.log(data.val)
}

Inherited from

McDbEntity.getxDataDouble


getxDataLong

getxDataLong(appName): Object

Retrieve the long (integer) value from the specified XData type of the entity

Parameters

NameTypeDescription
AppNamestringExtended Data Name

Returns

Object

Long value

NameType
retboolean
valnumber

Example

ts
//Assuming ent is a valid instance object
let data = ent.getxDataLong("DataName");
if(data.ret){
  console.log(data.val)
}

Inherited from

McDbEntity.getxDataLong


getxDataPoint

getxDataPoint(appName): Object

Retrieve point objects from the specified XData type of entity

Parameters

NameTypeDescription
AppNamestringExtended Data Name

Returns

Object

Obtain results and 3D point objects

NameType
retboolean
valMcGePoint3d

Inherited from

McDbEntity.getxDataPoint


getxDataString

getxDataString(appName): Object

Retrieve XData information associated with a specific entity and return it in string form

Parameters

NameTypeDescription
AppNamestringExtended Data Name

Returns

Object

Val XData information | whether ret returns success

NameType
retboolean
valstring

Example

ts
//Assuming ent is a valid instance object
let data = ent.getxDataString("DataName");
if(data.ret){
  console.log(data.val)
}

Inherited from

McDbEntity.getxDataString


hatchStyle

hatchStyle(): HatchStyle

Fill style

Returns

HatchStyle

Example

ts
//Hatch is an instance object for pattern filling
const style = hatch.hatchStyle();

highlight

highlight(isHighlight): void

Set whether the object is highlighted

Parameters

NameTypeDescription
IsHighlightbooleanIs it highlighted

Returns

void

Example

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

Inherited from

McDbEntity.highlight


initTempObject

initTempObject(imp): void

Initialize temporary objects.

Parameters

NameTypeDescription
'imp''any'Internal implementation object

Returns

void

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbEntity.initTempObject


isErased

isErased(): boolean

Has the object been deleted

Returns

boolean

Example

ts
//Assuming obj is a database object
const res = obj.isErased();
console.log(res);

Inherited from

McDbEntity.isErased


isHaveExtensionDictionary

isHaveExtensionDictionary(): boolean

Is there any extended dictionary data available

Returns

boolean

Example

ts
//Assuming obj is a database object
const res = obj.isHaveExtensionDictionary();

Inherited from

McDbEntity.isHaveExtensionDictionary


isKindOf

isKindOf(sObjectName): boolean

Determine object type

Parameters

NameTypeDescription
SOrtNamestringType Name

Returns

boolean

Return whether the object is of the target type

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
let isKind = obj.isKindOf('SomeObjectType');
console.log(isKind); //  Output: True or false

Inherited from

McDbEntity.isKindOf


isNull

isNull(): any

Determine if it is an empty object

Returns

any

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
console.log(obj.isNull()); //  Output: True or false

Inherited from

McDbEntity.isNull


isSolid

isSolid(): boolean

Check if the filled object is solid filled

Returns

boolean

Boolean value

Example

ts
//Hatch is an instance object for pattern filling
const res = hatch.isSolid();
if(res){
//Entity filling
}else{
//Non entity filling
}

loopTypeAt

loopTypeAt(loopIndex): number

Types in a closed area index

Parameters

NameType
loopIndexnumber

Returns

number

Example

ts
//Hatch is an instance object for pattern filling
const looptType = hatch.loopTypeAt(0)

mirror

mirror(point1, point2): boolean

Mirror oriented object

Parameters

NameTypeDescription
Point1[McGePoint3d] (2d. McGePoint3d. md)Mirror Base Point
point2McGePoint3d-

Returns

boolean

Example

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

Inherited from

McDbEntity.mirror


move

move(fromPoint, toPoint): boolean

move objects

Parameters

NameTypeDescription
From Point[McGePoint3d] (2d. McGePoint3d. md)Move the starting point
ToPoint[McGePoint3d] (2d. McGePoint3d. md)Move End Point

Returns

boolean

Example

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

Inherited from

McDbEntity.move


moveGripPointsAt

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

Control points for moving objects

Parameters

NameTypeDescription
IIndexNumberIndex
DXOffsetnumberX-axis offset
DYOffsetnumberY-axis offset
DZOffsetnumberZ-axis offset

Returns

any

Example

ts
//Assuming obj is a database object
obj.moveGripPointsAt(1,10,10,10);

Inherited from

McDbEntity.moveGripPointsAt


patternName

patternName(): string

Fill pattern name

Returns

string

Example

ts
//Hatch is an instance object for pattern filling
const patternName = hatch.patternName()

patternType

patternType(): number

Fill pattern type

Returns

number

Example

ts
//Hatch is an instance object for pattern filling
const type = hatch.patternType()

removeAllLoop

removeAllLoop(): boolean

Delete all closed areas

Returns

boolean

Example

ts
//Hatch is an instance object for pattern filling
const res = hatch.removeAllLoop();
if(res){
//Delete successfully
}else{
//Delete failed
}

removeLoopAt

removeLoopAt(loopIndex): boolean

Delete a closed region under a certain index

Parameters

NameTypeDescription
LoopIndexnumberIndex of removed loops

Returns

boolean

Example

ts
//Hatch is an instance object for pattern filling
const res = hatch.removeLoopAt(1);
if(res){
//Delete successfully
}else{
//Delete failed
}

rotate

rotate(basePoint, dRotationAngle): boolean

Rotate object

Parameters

NameTypeDescription
BasePoint[McGePoint3d] (2d. McGePoint3d. md)Rotate the base point
DRotationAnglenumberRotation angle

Returns

boolean

Example

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

Inherited from

McDbEntity.rotate


scaleEntity

scaleEntity(basePoint, dScaleFactor): boolean

Scaling objects

Parameters

NameTypeDescription
BasePoint[McGePoint3d] (2d. McGePoint3d. md)Scale Base Point
DScaleFactornumberscaling factor (<1 zoom out;>1 zoom in)

Returns

boolean

Example

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

Inherited from

McDbEntity.scaleEntity


scalePattern

scalePattern(scale): boolean

Scale the currently defined fill pattern data.

Parameters

NameType
scalenumber

Returns

boolean


setHatchStyle

setHatchStyle(val): void

Set fill style

Parameters

NameType
valHatchStyle

Returns

void

Example

ts
import { McDbHatch, McDb } from "mxcad"

McDbHatch.setHatchStyle(McDb.HatchStyle.kNormal)

setJson

setJson(str): boolean

Set a string in JSON format.

Parameters

NameTypeDescription
StrstringJSON formatted string

Returns

boolean

Is the setting successful.

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbEntity.setJson


setLoopAt

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

Set closed area data under a certain index

Parameters

NameTypeDefault valueDescription
LoopIndexnumberundefinedClosed area index
Vertices[McGePoint3dArray] (2d. McGePoint3dArray. md)undefinedCoordinate set
Bulgesnumber []undefinedconvexity set
loopTypenumber`McDb. HatchLoopType.kPolylineClosed Area Type

Returns

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 ("Loop setting successful! ");
} else {
Console.log ("Loop setting failed ");
}

setPattern

setPattern(type, patName): void

Set Fill Pattern

Parameters

NameTypeDescription
TypeNumberSource type of fill pattern
PatNamestringFill pattern name

Returns

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);

setxData

setxData(xdata): boolean

Set extended data for objects

Parameters

NameTypeDescription
Xdata[MxCADResbuf] (2d. MxCADResbuf. md)Extended data linked list

Returns

boolean

Example

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

//Set extended data
let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
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"}]));

Inherited from

McDbEntity.setxData


setxDataDouble

setxDataDouble(appName, val): boolean

Set the double value in the specified XData type of the entity

Parameters

NameTypeDescription
AppNamestringExtended Data Name
Valnumberdouble value

Returns

boolean

Boolean value

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
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){
//Setting successful
}else{
//Setting failed
}

Inherited from

McDbEntity.setxDataDouble


setxDataLong

setxDataLong(appName, val): boolean

Set the long (integer) value in the specified XData type of the entity

Parameters

NameTypeDescription
AppNamestringExtended Data Name
Valnumberlong value

Returns

boolean

Long value

Example

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

let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
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){
//Setting successful
}else{
//Setting failed
}

Inherited from

McDbEntity.setxDataLong


setxDataPoint

setxDataPoint(appName, val): boolean

Set the point object in the specified XData type of the entity

Parameters

NameTypeDescription
AppNamestringExtended Data Name
Val[McGePoint3d] (2d. McGePoint3d. md)Point Object

Returns

boolean

Obtain results and 3D point objects

Inherited from

McDbEntity.setxDataPoint


setxDataString

setxDataString(appName, val): boolean

Set XData information associated with a specific entity and set it in string form

Parameters

NameTypeDescription
AppNamestringExtended Data Name
Valstringstring value

Returns

boolean

Is the setting successful

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
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){
//Setting successful
}else{
//Setting failed
}

Inherited from

McDbEntity.setxDataString


syncData

syncData(_toCpp?): boolean

Synchronize entity data. This method may be called after modifying the entity's attributes or attaching new data to ensure that all changes are correctly saved to the entity's database records.

Parameters

NameTypeDefault valueDescription
_toCppbooleantrueWhether to synchronize data

Returns

boolean

Example

ts
//Assuming ent is a valid instance object
const res = ent.syncData(true);
if(res){
//Synchronization successful
}else{
//Synchronization failed
}

Inherited from

McDbEntity.syncData


transformBy

transformBy(transformationMatrix): boolean

Transform object

Parameters

NameTypeDescription
TransformationMatrix[McGeMatrix3d] (2d. McGeMatrix3d. md)Transformation Matrix

Returns

boolean

Example

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

Inherited from

McDbEntity.transformBy


unErase

unErase(): boolean

Anti delete object.

Returns

boolean

Example

ts
//Assuming obj is a database object
const res = obj.unErase();
console.log(res);

Inherited from

McDbEntity.unErase


updateDisplay

updateDisplay(): void

Display the updated display of the calling object

Returns

void

Example

ts
//Assuming ent is a valid instance object
ent.updateDisplay()

Inherited from

McDbEntity.updateDisplay