[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:
- First, retrieve a McDbObject from the object ID or database;
- Call methods such as getObject ID(), getDatabase (), and getHandle () to read object metadata;
- Use methods such as erase(), clone(), assertObject Modifier() to perform object operations;
- 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
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
↳
McDbObject↳↳
McDbXrecord↳↳
McDbGroup↳↳
McDbEntity
Table of contents
Constructors
Properties
Accessors
Methods
- assertObjectModification
- clone
- createExtensionDictionary
- erase
- getDatabase
- getDatabaseIndexId
- getExtensionDictionary
- getGripEditBasePointsIndex
- getGripPoints
- getHandle
- getImp
- getJson
- getObjectID
- getOwnerID
- initTempObject
- isErased
- isHaveExtensionDictionary
- isKindOf
- isNull
- moveGripPointsAt
- setJson
- unErase
Constructors
constructor
• new McDbObject(imp?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
imp? | Any | Internal implementation object |
Overrides
Properties
imp
• imp: any = 0
Internal implementation object.
Inherited from
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
| Name | Type | Default value | Description |
|---|---|---|---|
| AutoUndo | boolean | false | Should 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
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
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
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
getJson
▸ getJson(): string
Retrieve a string in JSON format.
Returns
string
A string in JSON format.
Inherited from
getObjectID
▸ getObjectID(): McObjectId
Get the object ID.
Returns
Object ID.
getOwnerID
▸ getOwnerID(): number
Obtain the ID of the object owner
Returns
number
initTempObject
▸ initTempObject(imp): void
Initialize temporary objects.
Parameters
| Name | Type | Description |
|---|---|---|
| 'imp' | 'any' | Internal implementation object |
Returns
void
Inherited from
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
| Name | Type | Description |
|---|---|---|
| SOrtName | string | Type Name |
Returns
boolean
Return whether the object is of the target type
Inherited from
isNull
▸ isNull(): any
Determine if it is an empty object
Returns
any
Inherited from
moveGripPointsAt
▸ moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset): any
Grips for moving objects
Parameters
| Name | Type | Description |
|---|---|---|
| IIndex | Number | Index |
| DXOffset | number | X-axis offset |
| DYOffset | number | Y-axis offset |
| DZOffset | number | Z-axis offset |
Returns
any
setJson
▸ setJson(str): boolean
Set a string in JSON format.
Parameters
| Name | Type | Description |
|---|---|---|
| Str | string | JSON formatted string |
Returns
boolean
Is the setting successful.
Inherited from
unErase
▸ unErase(): boolean
Anti delete object.
Returns
boolean
