[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/MxCADResbuf
Class: MxCADResbuf
2d.MxCADResbuf
The MxCADResbuf class is used to manipulate respuf data in AutoCAD.
Example
//Filter all text objects in the drawing
import { MxCADResbuf } from "mxcad"
//Define filtering
const filter = new MxCADResbuf();
filter.AddMcDbEntityTypes("TEXT,MTEXT");
//Set selection, filter text objects
let ss = new MxCADSelectionSet();
ss.allSelect(filter);
ss.forEach((id) => {
let ent: any = id.getMcDbEntity();
if (!ent) return;
ent = McDbEntityToJsonObject(ent);
console.log(JSON.stringify(ent));
})
Hierarchy
↳
MxCADResbuf
Table of contents
Constructors
Properties
Accessors
Methods
- AddAppName
- AddDouble
- AddLong
- AddMcDbEntityTypes
- AddObject
- AddObjectId
- AddPoint
- AddString
- AtDouble
- AtLong
- AtObject
- AtObjectId
- 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 } from "mxcad"
//Define filters to filter entity types: line, arc, circle, polyline
const filter = new MxCADResbuf([DxfCode.kEntityType, "LINE,ARC,CIRCLE,LWPOLYLINE"]));
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
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
console.log(obj.objectName);
Inherited from
McRxObject.objectName
Methods
AddAppName
▸ AddAppName(str
, decodeFromGb2312?
): number
Add extension data name and filter using selection set
Parameters
Name | Type | Default value |
---|---|---|
str | string | undefined |
decodeFromGb2312 | boolean | true |
Returns
number
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.
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AddDouble (3.14);
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.
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AddLong (42);
AddMcDbEntityTypes
▸ AddMcDbEntityTypes(str
): any
Add entity types for selection set 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 filters
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
Example
import { MxCADResbuf, McRxObject } from "mxcad"
//Define filters
const filter = new MxCADResbuf();
filter.AddObject( new McRxObject());
AddObjectId
▸ AddObjectId(val
, lDataType?
): number
Add the Object ID to the respuff.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
val | number | undefined | ObjectId。 |
LDataType | number | -10 | data type |
Returns
number
Index of added data items.
Example
import { MxCADResbuf, McDbObject } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
const objId = new McDbObject();
filter.AddObjectId (objId);
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.
Example
import { MxCADResbuf, McGePoint3d } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AddPoint (new McGePoint3d(10,20,0));
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.
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
Filter. AddString ("test string");
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 |
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
console.log(filter.AtDouble(0))
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 |
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
console.log(filter.AtLong(0))
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 |
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
console.log(filter.AtObject(0))
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 |
Example
import { MxCADResbuf } from "mxcad
const filter = new MxCADResbuf();
console.log(filter.AtObjectId(0))
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 |
Example
import { MxCADResbuf } from "mxcad
const filter = new MxCADResbuf();
console.log(filter.AtPoint(0))
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 |
Example
import { MxCADResbuf } from "mxcad
const filter = new MxCADResbuf();
console.log(filter.AtString(0))
Clear
▸ Clear(): void
Clear the respuff data.
Returns
void
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AddMcDbEntityTypes("TEXT,MTEXT");
filter.Clear();
Console. log (filter. FHIR ount())//Output 0
GetCount
▸ GetCount(): number
Retrieve the number of respuff data items.
Returns
number
The number of respuff data items.
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
Console. log (filter. FHIR ount())//Output 0
GetPoints
▸ GetPoints(): McGePoint3dArray
Retrieve all point data from the respuff.
Returns
Example
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
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
console.log(filter.ItemDataDxf(0))
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.
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
console.log(filter.ItemDataType(0))
PrintData
▸ PrintData(): void
Debugging input information
Returns
void
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
Filter. PrintData ("Debug Information")
Remove
▸ Remove(lItem
): void
Remove the respuff data item from the specified index.
Parameters
Name | Type | Description |
---|---|---|
List | Number | Data item index |
Returns
void
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AtLong (42);
filter.Remove(0);
RemoveAll
▸ RemoveAll(): void
Remove all respuff data items.
Returns
void
Example
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AtLong (42);
filter.RemoveAll();
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: 10
getImp
▸ getImp(): any
Retrieve internal implementation objects.
Returns
any
Internal implementation object.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
let imp = obj.getImp();
Inherited from
getJson
▸ getJson(): string
Retrieve a string in JSON format.
Returns
string
A string in JSON format.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
const json = obj.getJson()
Inherited from
initTempObject
▸ initTempObject(imp
): void
Initialize temporary objects.
Parameters
Name | Type | Description |
---|---|---|
'imp' | 'any' | Internal implementation object |
Returns
void
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
obj.initTempObject()
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
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
let isKind = obj.isKindOf('SomeObjectType');
console.log(isKind); // Output: True or false
Inherited from
isNull
▸ isNull(): any
Determine if it is an empty object
Returns
any
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
console.log(obj.isNull()); // Output: True or false
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.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
const res = obj.setJson('{"key": "value"}');
console.log(res)