Skip to content

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

Class: MxCADResbuf ​

2d.MxCADResbuf

MxCADResbuf is a container class used for constructing and reading CAD rule data.

Description

This class is used to encapsulate the respuff data structure in AutoCAD/MxCAD, and is commonly used in scenarios such as entity filtering, layer conditions, extended data queries, and object selection. It is essentially closer to a "data rule set/condition container", used to organize multiple query conditions into a unified data format, and then pass it to selection sets, command interaction, object queries, and other functions; It can also read data such as strings, values, points, object IDs, etc. Usage:

  1. Create a conditional container using new MxCADResbuf();
  2. Call methods such as AddMcDbElementTypes/AddString/AddPoint to add rule items;
  3. Pass the container to interfaces such as MxCADSelectionSet. allSelect(), MxCADUtility. findEntAtPoint(), etc;
  4. Use methods such as AtString/AtPoint/AtDouble/∝unt to read the data.

Example

ts
import { MxCADResbuf, MxCADSelectionSet } from "mxcad";

//Create a conditional container to filter only lines and circles
const rules = new MxCADResbuf();
rules.AddMcDbEntityTypes("LINE,CIRCLE");

const ss = new MxCADSelectionSet();
ss.allSelect(rules);
Console.log ("Current number of selected set objects:", ss. count());

Hierarchy ​

Table of contents ​

Constructors ​

Properties ​

Accessors ​

Methods ​

Constructors ​

constructor ​

• new MxCADResbuf(imp?)

Constructor.

Parameters ​

NameTypeDescription
imp?AnyInternal implementation object

Example

ts
import { MxCADResbuf, DxfCode, MxCADSelectionSet } from "mxcad"

let ss = new MxCADSelectionSet();
//Define filtering criteria to limit entity types: line, arc, circle, polyline
const filter1 = new MxCADResbuf([DxfCode.kEntityType, "LINE,ARC,CIRCLE,LWPOLYLINE"]));
ss.allSelect(filter1);

//Obtain objects on the graph, including straight lines, circles, arcs, polylines, and at level 0
  const filter2 = new MxCADResbuf([DxfCode.kEntityType, "LINE,ARC,CIRCLE,LWPOLYLINE", DxfCode.kLayer, "0"]);
  ss.allSelect(filter2);

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 ​

AddAppName ​

▸ AddAppName(str, decodeFromGb2312?): number

Add extension data name for selecting set rule filtering

Parameters ​

NameTypeDefault valueDescription
StrstringundefinedExtended data name
DecodeFromGb2312booleantrueWhether to encode and decode from GB2312, default to true

Returns ​

number

Index of added data items


AddDouble ​

▸ AddDouble(val, lDataType?): number

Add a double value to the respuff.

Parameters ​

NameTypeDefault valueDescription
Valnumberundefineddouble type value
LDataTypenumber-10data type

Returns ​

number

Index of added data items.


AddLong ​

▸ AddLong(val, lDataType?): number

Add a long type value to the respuff.

Parameters ​

NameTypeDefault valueDescription
Valnumberundefinedlong type value
LDataTypenumber-10data type

Returns ​

number

Index of added data items.


AddMcDbEntityTypes ​

▸ AddMcDbEntityTypes(str): any

Add entity type for selecting set rule filtering

Parameters ​

NameTypeDescription
Using multiple types, such as: "TEXT,MTEXT"

Returns ​

any

Description

Type table of entities

TypeDescription
POINTText
TextText
MTEXTMulti line Text
CIRCLECircle
ARCArc
LINELine
LWPOLYLINEPolyline
InsertBlock
ELLIPSEEllipse
SPLINESpline Line
LinkLineHyperlinks

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filtering criteria
const filter = new MxCADResbuf()
filter.AddMcDbEntityTypes ("TEXT,LINE");

AddObject ​

▸ AddObject(pObj): void

Add McRxObject object to respuff

Parameters ​

NameTypeDescription
PObjMcRxObject (2d. McRxObject. md)McRxObject Example Object

Returns ​

void


AddObjectId ​

▸ AddObjectId(val, lDataType?): number

Add the Object ID to the respuff.

Parameters ​

NameTypeDefault valueDescription
valnumber | BigIntundefinedObjectId。
LDataTypenumber-10data type

Returns ​

number

Index of added data items.


AddPoint ​

▸ AddPoint(pt, lDataType?): number

Add point coordinates to the respuff.

Parameters ​

NameTypeDefault valueDescription
Pt[McGePoint3d] (2d. McGePoint3d. md)undefinedPoint coordinates
LDataTypenumber-10data type

Returns ​

number

Index of added data items.


AddString ​

▸ AddString(str, lDataType?, decodeFromGb2312?): number

Add a string to the respuff.

Parameters ​

NameTypeDefault valueDescription
Strstringundefinedstring
LDataTypenumber-10data type
decodeFromGb2312booleantrue-

Returns ​

number

Index of added data items.


AtDouble ​

▸ AtDouble(lItem): Object

Retrieve the double type value from the respuff data item.

Parameters ​

NameTypeDescription
ListNumberData item index

Returns ​

Object

An object that contains a double type value and a return value.

NameType
retboolean
valnumber

AtLong ​

▸ AtLong(lItem): Object

Retrieve the long type value from the respuff data item.

Parameters ​

NameTypeDescription
ListNumberData item index

Returns ​

Object

An object that contains a long type value and a return value.

NameType
retboolean
valnumber

AtObject ​

▸ AtObject(lItem): Object

Retrieve the McRxObject object from the respuff data item.

Parameters ​

NameTypeDescription
ListNumberData item index

Returns ​

Object

An object that contains database objects and return values.

NameType
retboolean
valundefined | McDbObject

AtObjectId ​

▸ AtObjectId(lItem): Object

Retrieve the Object ID from the respuff data item.

Parameters ​

NameTypeDescription
ListNumberData item index

Returns ​

Object

An object that contains an Object Id and a return value.

NameType
retboolean
valMcObjectId

AtObjectIdValue ​

▸ AtObjectIdValue(lItem): Object

Retrieve the Object Id value from the respuff data item.

Parameters ​

NameTypeDescription
ListNumberData item index

Returns ​

Object

NameType
retboolean
valnumber

AtPoint ​

▸ AtPoint(lItem): Object

Retrieve the point coordinates from the respuff data item.

Parameters ​

NameTypeDescription
ListNumberData item index

Returns ​

Object

An object that contains point coordinates and return values.

NameType
retboolean
valMcGePoint3d

AtString ​

▸ AtString(lItem, decodeFromGb2312?): Object

Retrieve the string from the respuff data item.

Parameters ​

NameTypeDefault valueDescription
Listnumberundefineddata item index
decodeFromGb2312booleantrue-

Returns ​

Object

An object that contains a string and a return value.

NameType
retboolean
valstring

Clear ​

▸ Clear(): void

Clear the respuff data.

Returns ​

void


GetCount ​

▸ GetCount(): number

Retrieve the number of respuff data items.

Returns ​

number

The number of respuff data items.


GetPoints ​

▸ GetPoints(): McGePoint3dArray

Retrieve all point data from the respuff.

Returns ​

McGePoint3dArray


ItemDataDxf ​

▸ ItemDataDxf(index): number

Retrieve the DXF value of the data in the respuff data item

Parameters ​

NameTypeDescription
Indexnumberindex value

Returns ​

number

DXF value


ItemDataType ​

▸ ItemDataType(index): number

Retrieve the data type from the respuff data item.

Parameters ​

NameTypeDescription
Indexnumberindex value

Returns ​

number

Data type.


PrintData ​

▸ PrintData(): void

Debugging input information

Returns ​

void


Remove ​

▸ Remove(lItem): void

Remove the respuff data item from the specified index.

Parameters ​

NameTypeDescription
ListNumberData item index

Returns ​

void


RemoveAll ​

▸ RemoveAll(): void

Remove all respuff data items.

Returns ​

void


forEach ​

▸ forEach(call): void

Traverse the data.

Parameters ​

NameTypeDescription
Call(val: any, type: number, dxf: number, index: number)=>voidA callback function that takes three parameters (val: the value of the element, type: Element type, dxf: Data exchange format for elements

Returns ​

void

Example

ts
  import {MxCADResbuf} from "mxcad"

//Create MxCADResbuf instance
  const cadResbuf = new MxCADResbuf();
cadResbuf.AddPoint(new McGePoint3d(1,2,3));// Add a point element
cadResbuf.AddString(“Hello”);// Add a string element
cadResbuf.AddDouble (3.14);// Add double precision data
cadResbuf.AddLong (42);// Add an integer data

//Iterate elements in CAD Resuff instances
  cadResbuf.forEach((val, type, dxf)=>{
Console.log (Value: ",val);
Console.log (Type: ",type);
   console.log("DXF:",DXF);
   });
//Output:
//Value: {x: 1, y: 2, z: 3}
//Type: 5009
   // dxf: 10
//Value: Hello
//Type: 5005
   // dxf: 10
//Value: 3.14
//Type: 5001
   // dxf: 10
//Value: 42
//Type: 5010
   // dxf: 10

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


initTempObject ​

▸ initTempObject(imp): void

Initialize temporary objects.

Parameters ​

NameTypeDescription
'imp''any'Internal implementation object

Returns ​

void

Inherited from ​

McRxObject.initTempObject


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


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