[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:
- Create a conditional container using new MxCADResbuf();
- Call methods such as AddMcDbElementTypes/AddString/AddPoint to add rule items;
- Pass the container to interfaces such as MxCADSelectionSet. allSelect(), MxCADUtility. findEntAtPoint(), etc;
- Use methods such as AtString/AtPoint/AtDouble/∝unt to read the data.
Example
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
↳
MxCADResbuf
Table of contents
Constructors
Properties
Accessors
Methods
- AddAppName
- AddDouble
- AddLong
- AddMcDbEntityTypes
- AddObject
- AddObjectId
- AddPoint
- AddString
- AtDouble
- AtLong
- AtObject
- AtObjectId
- AtObjectIdValue
- AtPoint
- AtString
- Clear
- GetCount
- GetPoints
- ItemDataDxf
- ItemDataType
- PrintData
- Remove
- RemoveAll
- forEach
- getImp
- getJson
- initTempObject
- isKindOf
- isNull
- setJson
Constructors
constructor
• new MxCADResbuf(imp?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
imp? | Any | Internal implementation object |
Example
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
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
AddAppName
▸ AddAppName(str, decodeFromGb2312?): number
Add extension data name for selecting set rule filtering
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| Str | string | undefined | Extended data name |
| DecodeFromGb2312 | boolean | true | Whether 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
| Name | Type | Default value | Description |
|---|---|---|---|
| Val | number | undefined | double type value |
| LDataType | number | -10 | data type |
Returns
number
Index of added data items.
AddLong
▸ AddLong(val, lDataType?): number
Add a long type value to the respuff.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| Val | number | undefined | long type value |
| LDataType | number | -10 | data type |
Returns
number
Index of added data items.
AddMcDbEntityTypes
▸ AddMcDbEntityTypes(str): any
Add entity type for selecting set rule filtering
Parameters
| Name | Type | Description |
|---|---|---|
| Using multiple types, such as: "TEXT,MTEXT" |
Returns
any
Description
Type table of entities
| Type | Description |
|---|---|
| POINT | Text |
| Text | Text |
| MTEXT | Multi line Text |
| CIRCLE | Circle |
| ARC | Arc |
| LINE | Line |
| LWPOLYLINE | Polyline |
| Insert | Block |
| ELLIPSE | Ellipse |
| SPLINE | Spline Line |
| LinkLine | Hyperlinks |
Example
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
| Name | Type | Description |
|---|---|---|
| PObj | McRxObject (2d. McRxObject. md) | McRxObject Example Object |
Returns
void
AddObjectId
▸ AddObjectId(val, lDataType?): number
Add the Object ID to the respuff.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
val | number | BigInt | undefined | ObjectId。 |
| LDataType | number | -10 | data type |
Returns
number
Index of added data items.
AddPoint
▸ AddPoint(pt, lDataType?): number
Add point coordinates to the respuff.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| Pt | [McGePoint3d] (2d. McGePoint3d. md) | undefined | Point coordinates |
| LDataType | number | -10 | data type |
Returns
number
Index of added data items.
AddString
▸ AddString(str, lDataType?, decodeFromGb2312?): number
Add a string to the respuff.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| Str | string | undefined | string |
| LDataType | number | -10 | data type |
decodeFromGb2312 | boolean | true | - |
Returns
number
Index of added data items.
AtDouble
▸ AtDouble(lItem): Object
Retrieve the double type value from the respuff data item.
Parameters
| Name | Type | Description |
|---|---|---|
| List | Number | Data item index |
Returns
Object
An object that contains a double type value and a return value.
| Name | Type |
|---|---|
ret | boolean |
val | number |
AtLong
▸ AtLong(lItem): Object
Retrieve the long type value from the respuff data item.
Parameters
| Name | Type | Description |
|---|---|---|
| List | Number | Data item index |
Returns
Object
An object that contains a long type value and a return value.
| Name | Type |
|---|---|
ret | boolean |
val | number |
AtObject
▸ AtObject(lItem): Object
Retrieve the McRxObject object from the respuff data item.
Parameters
| Name | Type | Description |
|---|---|---|
| List | Number | Data item index |
Returns
Object
An object that contains database objects and return values.
| Name | Type |
|---|---|
ret | boolean |
val | undefined | McDbObject |
AtObjectId
▸ AtObjectId(lItem): Object
Retrieve the Object ID from the respuff data item.
Parameters
| Name | Type | Description |
|---|---|---|
| List | Number | Data item index |
Returns
Object
An object that contains an Object Id and a return value.
| Name | Type |
|---|---|
ret | boolean |
val | McObjectId |
AtObjectIdValue
▸ AtObjectIdValue(lItem): Object
Retrieve the Object Id value from the respuff data item.
Parameters
| Name | Type | Description |
|---|---|---|
| List | Number | Data item index |
Returns
Object
| Name | Type |
|---|---|
ret | boolean |
val | number |
AtPoint
▸ AtPoint(lItem): Object
Retrieve the point coordinates from the respuff data item.
Parameters
| Name | Type | Description |
|---|---|---|
| List | Number | Data item index |
Returns
Object
An object that contains point coordinates and return values.
| Name | Type |
|---|---|
ret | boolean |
val | McGePoint3d |
AtString
▸ AtString(lItem, decodeFromGb2312?): Object
Retrieve the string from the respuff data item.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| List | number | undefined | data item index |
decodeFromGb2312 | boolean | true | - |
Returns
Object
An object that contains a string and a return value.
| Name | Type |
|---|---|
ret | boolean |
val | string |
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
ItemDataDxf
▸ ItemDataDxf(index): number
Retrieve the DXF value of the data in the respuff data item
Parameters
| Name | Type | Description |
|---|---|---|
| Index | number | index value |
Returns
number
DXF value
ItemDataType
▸ ItemDataType(index): number
Retrieve the data type from the respuff data item.
Parameters
| Name | Type | Description |
|---|---|---|
| Index | number | index 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
| Name | Type | Description |
|---|---|---|
| List | Number | Data item index |
Returns
void
RemoveAll
▸ RemoveAll(): void
Remove all respuff data items.
Returns
void
forEach
▸ forEach(call): void
Traverse the data.
Parameters
| Name | Type | Description |
|---|---|---|
| Call | (val: any, type: number, dxf: number, index: number)=>void | A callback function that takes three parameters (val: the value of the element, type: Element type, dxf: Data exchange format for elements |
Returns
void
Example
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: 10getImp
▸ 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
initTempObject
▸ initTempObject(imp): void
Initialize temporary objects.
Parameters
| Name | Type | Description |
|---|---|---|
| 'imp' | 'any' | Internal implementation object |
Returns
void
Inherited from
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
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.
