Skip to content

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

Class: McObjectId ​

2d.McObjectId

McObjectid is an identifier for object instances in MxCAD, responsible for describing the reference of a CAD object in the database.

Description

This class is used to represent the ID of an object and carries object type information, facilitating bridging between the underlying database and TypeScript side. It can accomplish: -Determine whether the object ID is valid or empty; -Delete objects and query object status; -Convert the object ID into corresponding objects such as McDbObject/McDbEntity/McDbCurve; -Confirm whether the object belongs to a certain CAD class through type judgment.

Usage:

  1. Obtain McObjectid through object operation results or drawing commands;
  2. Call isValid(), isNull(), isKindOf() for judgment;
  3. Combine methods such as getMcDbObject () and getMcDbEntity () to obtain real object instances and continue editing.

Summary: In practical development, McObjectid is the entry point for CAD object access, usually used to obtain object references in the database, and then continue to perform operations such as selection, query, deletion, and conversion.

Example

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

async function testObjectId() {
  const mxcad = MxCpp.getCurrentMxCAD();
  const line = new McDbLine(new McGePoint3d(0, 0, 0), new McGePoint3d(100, 0, 0));
  const id = mxcad.drawEntity(line);

  if (!id || id.isNull()) {
Console.log ("Object creation failed");
    return;
  }

Console.log ("Object validity:", id.isValid());
Console.log ("Object is empty:", id. isPull());
Console.log ("Object is a line:", id.isKindOf ("McDbLine"));

  const ent = id.getMcDbEntity();
  if (ent) {
Console.log ("Entity type:", ent. objectName);
  }
}

Table of contents ​

Constructors ​

Properties ​

Methods ​

Constructors ​

constructor ​

• new McObjectId(id?, type?)

Create an instance of McObjectid.

Parameters ​

NameTypeDefault valueDescription
The unique identifier of the 'id''number''0'object
Type[McObject IdType] (../enums/2d. McObject IdType. md)McObject IdType. kInvalidThe type of the object

Properties ​

id ​

• id: number

Object ID


type ​

• type: McObjectIdType

object type

Methods ​

clone ​

▸ clone(): null | McDbObject

Clone object

Returns ​

null | McDbObject

Return cloned database objects


erase ​

▸ erase(isErase?): void

Delete object.

Parameters ​

NameTypeDefault valueDescription
IsErasebooleantrueDo you want to delete it

Returns ​

void


getMcDbBlockTableRecord ​

▸ getMcDbBlockTableRecord(): null | McDbBlockTableRecord

Return the MxCAD block table record object.

Returns ​

null | McDbBlockTableRecord


getMcDbCurve ​

▸ getMcDbCurve(): null | McDbCurve

Return the MxCAD McDbCurve object.

Returns ​

null | McDbCurve


getMcDbCustomEntity ​

▸ getMcDbCustomEntity(): null | McDbCustomEntity

Get custom entity

Returns ​

null | McDbCustomEntity


getMcDbDictionary ​

▸ getMcDbDictionary(): null | McDbDictionary

Retrieve dictionary information from the database

Returns ​

null | McDbDictionary


getMcDbDimStyleTableRecord ​

▸ getMcDbDimStyleTableRecord(): null | McDbDimStyleTableRecord

Return the MxCAD annotation sample table record object.

Returns ​

null | McDbDimStyleTableRecord


getMcDbDimension ​

▸ getMcDbDimension(): null | McDbDimension

Return the MxCAD McDbDimension object.

Returns ​

null | McDbDimension


getMcDbEntity ​

▸ getMcDbEntity(): null | McDbEntity

Return the MxCAD McDbEntity object.

Returns ​

null | McDbEntity


getMcDbGroup ​

▸ getMcDbGroup(): null | McDbGroup

Return the MxCAD McDbGroup object.

Returns ​

null | McDbGroup


getMcDbLayerTableRecord ​

▸ getMcDbLayerTableRecord(): null | McDbLayerTableRecord

Return the recorded objects in the MxCAD layer table.

Returns ​

null | McDbLayerTableRecord


getMcDbLinetypeTableRecord ​

▸ getMcDbLinetypeTableRecord(): null | McDbLinetypeTableRecord

Return the MxCAD line type table record object.

Returns ​

null | McDbLinetypeTableRecord


getMcDbObject ​

▸ getMcDbObject(): null | McDbObject

Return the MxCAD McDbObject object.

Returns ​

null | McDbObject

Return a database object


getMcDbRasterImageDef ​

▸ getMcDbRasterImageDef(): null | McDbRasterImageDef

Obtain raster image information

Returns ​

null | McDbRasterImageDef


getMcDbTextStyleTableRecord ​

▸ getMcDbTextStyleTableRecord(): null | McDbTextStyleTableRecord

Return the MxCAD text style sheet record object.

Returns ​

null | McDbTextStyleTableRecord


getMcDbXrecord ​

▸ getMcDbXrecord(): null | McDbXrecord

Retrieve extended record information

Returns ​

null | McDbXrecord


getMxDbEntity ​

▸ getMxDbEntity(): null | MxDbEntity

Return the MxDraw object.

Returns ​

null | MxDbEntity


getObjectName ​

▸ getObjectName(): string

Return the name of the object pointed to by the ID

Returns ​

string


isErase ​

▸ isErase(): boolean

Is the ID pointing to the object in a deleted state

Returns ​

boolean

Boolean value


isKindOf ​

▸ isKindOf(className): boolean

Determine the type of an object

Parameters ​

NameTypeDescription
ClassNamestringType Name

Returns ​

boolean


isNull ​

▸ isNull(): boolean

Is the ID NULL

Returns ​

boolean

Boolean value


isValid ​

▸ isValid(): boolean

Is the ID valid

Returns ​

boolean

Boolean value