[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:
- Obtain McObjectid through object operation results or drawing commands;
- Call isValid(), isNull(), isKindOf() for judgment;
- 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
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
- clone
- erase
- getMcDbBlockTableRecord
- getMcDbCurve
- getMcDbCustomEntity
- getMcDbDictionary
- getMcDbDimStyleTableRecord
- getMcDbDimension
- getMcDbEntity
- getMcDbGroup
- getMcDbLayerTableRecord
- getMcDbLinetypeTableRecord
- getMcDbObject
- getMcDbRasterImageDef
- getMcDbTextStyleTableRecord
- getMcDbXrecord
- getMxDbEntity
- getObjectName
- isErase
- isKindOf
- isNull
- isValid
Constructors
constructor
• new McObjectId(id?, type?)
Create an instance of McObjectid.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| The unique identifier of the 'id' | 'number' | '0' | object |
| Type | [McObject IdType] (../enums/2d. McObject IdType. md) | McObject IdType. kInvalid | The 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
| Name | Type | Default value | Description |
|---|---|---|---|
| IsErase | boolean | true | Do 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
| Name | Type | Description |
|---|---|---|
| ClassName | string | Type 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
