Skip to content

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

Class: McDbGroup

2d.McDbGroup

McDbGroup is a grouping object in drawings, used to organize multiple objects into a logical collection.

Description

This class is used to manage the overall selection, naming, and description information of a group of objects, facilitating unified processing of multiple objects. It can accomplish: -Create a set of object collections; -Set group name and description; -Is the control group optional; -Save and query groups through the group dictionary in the database.

Usage:

  1. Select multiple objects first;
  2. Call the database's CreateGroup() to create a group;
  3. Control group properties through name, description, and isSelectable;
  4. Subsequently, perform overall management or selection processing according to the group objects.

Summary: In practical development, McDbGroup is the core type of object grouping management, suitable for batch processing, unified selection, and organizational management.

Example

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

//Create and manage graphic grouping objects.
async function testGroup() {
  const ss = new MxCADSelectionSet();
Const ok=await ss.userSelect ("Select objects to group");
  if (!ok) return;

  const mxcad = MxCpp.getCurrentMxCAD();
  const group = new McDbGroup();
  group.name = "MyGroup";
Group. description="test group";
  mxcad.getDatabase().CreateGroup(ss.getIds(), group.name);
}

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new McDbGroup(imp?)

Constructor.

Parameters

NameType
imp?any

Overrides

McDbObject.constructor

Properties

imp

imp: any = 0

Internal implementation object.

Inherited from

McDbObject.imp

Accessors

description

get description(): string

Returns

string

set description(description): void

Explanation Content

Parameters

NameType
descriptionstring

Returns

void


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

McDbObject.dxf0


isSelectable

get isSelectable(): boolean

Returns

boolean

set isSelectable(val): void

Do you want to choose an operation

Parameters

NameType
valboolean

Returns

void


name

get name(): string

Returns

string

set name(name): void

Group Name

Parameters

NameType
namestring

Returns

void


objectName

get objectName(): string

Get the object name.

Returns

string

Return object name

Inherited from

McDbObject.objectName

Methods

append

append(id): boolean

Add objects to the group

Parameters

NameType
idMcObjectId

Returns

boolean


appendArray

appendArray(aryId): boolean

Add object array to group

Parameters

NameType
aryIdMcObjectId[]

Returns

boolean


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

Inherited from

McDbObject.assertObjectModification


clear

clear(): boolean

Clear group

Returns

boolean


clone

clone(): null | McDbObject

Clone objects.

Returns

null | McDbObject

The cloned object.

Inherited from

McDbObject.clone


createExtensionDictionary

createExtensionDictionary(): boolean

Create extended dictionary data for objects

Returns

boolean

Inherited from

McDbObject.createExtensionDictionary


erase

erase(): boolean

Delete object.

Returns

boolean

Whether the deletion was successful.

Inherited from

McDbObject.erase


getAllEntityId

getAllEntityId(): McObjectId[]

Get all objects in the group

Returns

McObjectId[]


getDatabase

getDatabase(): McDbDatabase

Get the database where the object is located

Returns

McDbDatabase

Return to database

Inherited from

McDbObject.getDatabase


getDatabaseIndexId

getDatabaseIndexId(): number

Get the index ID of the object

Returns

number

Inherited from

McDbObject.getDatabaseIndexId


getExtensionDictionary

getExtensionDictionary(): McDbDictionary

Obtain the extended dictionary data of the object

Returns

McDbDictionary

Expand dictionary data

Inherited from

McDbObject.getExtensionDictionary


getGripEditBasePointsIndex

getGripEditBasePointsIndex(): number[]

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

Returns

number[]

Inherited from

McDbObject.getGripEditBasePointsIndex


getGripPoints

getGripPoints(): McGePoint3dArray

Get the grip array of the object

Returns

McGePoint3dArray

Inherited from

McDbObject.getGripPoints


getHandle

getHandle(): string

Obtain object handle

Returns

string

Return object handle

Inherited from

McDbObject.getHandle


getImp

getImp(): any

Retrieve internal implementation objects.

Returns

any

Internal implementation object.

Inherited from

McDbObject.getImp


getJson

getJson(): string

Retrieve a string in JSON format.

Returns

string

A string in JSON format.

Inherited from

McDbObject.getJson


getObjectID

getObjectID(): McObjectId

Get the object ID.

Returns

McObjectId

Object ID.

Inherited from

McDbObject.getObjectID


getOwnerID

getOwnerID(): number

Obtain the ID of the object owner

Returns

number

Inherited from

McDbObject.getOwnerID


has

has(id): boolean

Is there this object in the group

Parameters

NameType
idMcObjectId

Returns

boolean


initTempObject

initTempObject(imp): void

Initialize temporary objects.

Parameters

NameTypeDescription
'imp''any'Internal implementation object

Returns

void

Inherited from

McDbObject.initTempObject


isErased

isErased(): boolean

Has the object been deleted

Returns

boolean

Inherited from

McDbObject.isErased


isHaveExtensionDictionary

isHaveExtensionDictionary(): boolean

Is there any extended dictionary data available

Returns

boolean

Inherited from

McDbObject.isHaveExtensionDictionary


isKindOf

isKindOf(sObjectName): boolean

Determine object type

Parameters

NameTypeDescription
SOrtNamestringType Name

Returns

boolean

Return whether the object is of the target type

Inherited from

McDbObject.isKindOf


isNull

isNull(): any

Determine if it is an empty object

Returns

any

Inherited from

McDbObject.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

Inherited from

McDbObject.moveGripPointsAt


numEntities

numEntities(): number

Get the number of all objects in the group

Returns

number


setJson

setJson(str): boolean

Set a string in JSON format.

Parameters

NameTypeDescription
StrstringJSON formatted string

Returns

boolean

Is the setting successful.

Inherited from

McDbObject.setJson


unErase

unErase(): boolean

Anti delete object.

Returns

boolean

Inherited from

McDbObject.unErase