Skip to content

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

Class: McDbObject ​

2d.McDbObject

McDbObject is the basic class of database objects, responsible for carrying the universal capabilities of various objects in CAD databases.

Description

This class is used to represent an object entity in a graph database and provides a universal object operation interface. It can accomplish: -Obtain object ID, handle, database, owner, and extended dictionary; -Delete, de delete, clone objects; -Determine whether the object has been deleted; -Trigger object modification events and update graphic display; -As a common base class for all database entity objects, it provides unified behavior for derived classes.

Usage:

  1. First, retrieve a McDbObject from the object ID or database;
  2. Call methods such as getObject ID(), getDatabase (), and getHandle () to read object metadata;
  3. Use methods such as erase(), clone(), assertObject Modifier() to perform object operations;
  4. Further convert the object type to a specific entity object to continue editing.

Summary: In practical development, McDbObject is mainly used to unify the general properties and basic operations of database objects, and is the basic abstraction layer for all CAD solid objects.

Example

ts
import { MxCpp, McDbLine, McGePoint3d } from "mxcad";

async function testDbObject() {
  const mxcad = MxCpp.getCurrentMxCAD();
  const line = new McDbLine(new McGePoint3d(0, 0, 0), new McGePoint3d(200, 0, 0));
  const id = mxcad.drawEntity(line);
  if (!id || id.isNull()) return;

  const obj = id.getMcDbObject();
  if (!obj) return;

  const objectId = obj.getObjectID();
Console.log ("Object ID:", objectId);
Console. log ("Object Handle:", obj. getHandle());
Console. log ("Object location database:", obj. getDB2());

  const isErased = obj.isErased();
Console.log ("whether deleted:", isErased);
}

Hierarchy ​

Table of contents ​

Constructors ​

Properties ​

Accessors ​

Methods ​

Constructors ​

constructor ​

• new McDbObject(imp?)

Constructor.

Parameters ​

NameTypeDescription
imp?AnyInternal implementation object

Overrides ​

McRxObject.constructor

Properties ​

imp ​

• imp: any = 0

Internal implementation object.

Inherited from ​

McRxObject.imp

Accessors ​

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 ​

McRxObject.dxf0


objectName ​

• get objectName(): string

Get the object name.

Returns ​

string

Return object name

Inherited from ​

McRxObject.objectName

Methods ​

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 valueDescription
AutoUndobooleanfalseShould this modification automatically support undo? Default is false

Returns ​

number


clone ​

▸ clone(): null | McDbObject

Clone objects.

Returns ​

null | McDbObject

The cloned object.


createExtensionDictionary ​

▸ createExtensionDictionary(): boolean

Create extended dictionary data for objects

Returns ​

boolean


erase ​

▸ erase(): boolean

Delete object.

Returns ​

boolean

Whether the deletion was successful.


getDatabase ​

▸ getDatabase(): McDbDatabase

Get the database where the object is located

Returns ​

McDbDatabase

Return to database


getDatabaseIndexId ​

▸ getDatabaseIndexId(): number

Get the index ID of the object

Returns ​

number


getExtensionDictionary ​

▸ getExtensionDictionary(): McDbDictionary

Obtain the extended dictionary data of the object

Returns ​

McDbDictionary

Expand dictionary data


getGripEditBasePointsIndex ​

▸ getGripEditBasePointsIndex(): number[]

Retrieve the edit base point index corresponding to the grip of the object.

Returns ​

number[]


getGripPoints ​

▸ getGripPoints(): McGePoint3dArray

Get the grip array of the object

Returns ​

McGePoint3dArray


getHandle ​

▸ getHandle(): string

Obtain object handle

Returns ​

string

Return object handle


getImp ​

▸ getImp(): any

Retrieve internal implementation objects.

Returns ​

any

Internal implementation object.

Inherited from ​

McRxObject.getImp


getJson ​

▸ getJson(): string

Retrieve a string in JSON format.

Returns ​

string

A string in JSON format.

Inherited from ​

McRxObject.getJson


getObjectID ​

▸ getObjectID(): McObjectId

Get the object ID.

Returns ​

McObjectId

Object ID.


getOwnerID ​

▸ getOwnerID(): number

Obtain the ID of the object owner

Returns ​

number


initTempObject ​

▸ initTempObject(imp): void

Initialize temporary objects.

Parameters ​

NameTypeDescription
'imp''any'Internal implementation object

Returns ​

void

Inherited from ​

McRxObject.initTempObject


isErased ​

▸ isErased(): boolean

Has the object been deleted

Returns ​

boolean


isHaveExtensionDictionary ​

▸ isHaveExtensionDictionary(): boolean

Is there any extended dictionary data available

Returns ​

boolean


isKindOf ​

▸ isKindOf(sObjectName): boolean

Determine object type

Parameters ​

NameTypeDescription
SOrtNamestringType Name

Returns ​

boolean

Return whether the object is of the target type

Inherited from ​

McRxObject.isKindOf


isNull ​

▸ isNull(): any

Determine if it is an empty object

Returns ​

any

Inherited from ​

McRxObject.isNull


moveGripPointsAt ​

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

Grips for moving objects

Parameters ​

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

Returns ​

any


setJson ​

▸ setJson(str): boolean

Set a string in JSON format.

Parameters ​

NameTypeDescription
StrstringJSON formatted string

Returns ​

boolean

Is the setting successful.

Inherited from ​

McRxObject.setJson


unErase ​

▸ unErase(): boolean

Anti delete object.

Returns ​

boolean