Skip to content
On this page

[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

ts
//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

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new MxCADResbuf(imp?)

Constructor.

Example

ts
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"]));

Parameters

NameTypeDescription
imp?AnyInternal implementation object

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.

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
console.log(obj.objectName);

Returns

string

Return object name

Inherited from

McRxObject.objectName

Methods

AddAppName

AddAppName(str, decodeFromGb2312?): number

Add extension data name and filter using selection set

Parameters

NameTypeDefault value
strstringundefined
decodeFromGb2312booleantrue

Returns

number


AddDouble

AddDouble(val, lDataType?): number

Add a double value to the respuff.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AddDouble (3.14);

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.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AddLong (42);

Parameters

NameTypeDefault valueDescription
Valnumberundefinedlong type value
LDataTypenumber-10data type

Returns

number

Index of added data items.


AddMcDbEntityTypes

AddMcDbEntityTypes(str): any

Add entity types for selection set filtering

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 filters
const filter = new MxCADResbuf()
filter.AddMcDbEntityTypes ("TEXT,LINE");

Parameters

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

Returns

any


AddObject

AddObject(pObj): void

Add McRxObject object to respuff

Example

ts
import { MxCADResbuf, McRxObject } from "mxcad"
//Define filters
const filter = new MxCADResbuf();
filter.AddObject( new McRxObject());

Parameters

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

Returns

void


AddObjectId

AddObjectId(val, lDataType?): number

Add the Object ID to the respuff.

Example

ts
import { MxCADResbuf, McDbObject } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
const objId = new McDbObject();
filter.AddObjectId (objId);

Parameters

NameTypeDefault valueDescription
valnumberundefinedObjectId。
LDataTypenumber-10data type

Returns

number

Index of added data items.


AddPoint

AddPoint(pt, lDataType?): number

Add point coordinates to the respuff.

Example

ts
import { MxCADResbuf, McGePoint3d } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AddPoint (new McGePoint3d(10,20,0));

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.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
Filter. AddString ("test string");

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.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
console.log(filter.AtDouble(0))

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.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
console.log(filter.AtLong(0))

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.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
console.log(filter.AtObject(0))

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.

Example

ts
import { MxCADResbuf } from "mxcad

const filter = new MxCADResbuf();
console.log(filter.AtObjectId(0))

Parameters

NameTypeDescription
ListNumberData item index

Returns

Object

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

NameType
retboolean
valMcObjectId

AtPoint

AtPoint(lItem): Object

Retrieve the point coordinates from the respuff data item.

Example

ts
import { MxCADResbuf } from "mxcad

const filter = new MxCADResbuf();
console.log(filter.AtPoint(0))

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.

Example

ts
import { MxCADResbuf } from "mxcad

const filter = new MxCADResbuf();
console.log(filter.AtString(0))

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.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AddMcDbEntityTypes("TEXT,MTEXT");
filter.Clear();
Console. log (filter. FHIR ount())//Output 0

Returns

void


GetCount

GetCount(): number

Retrieve the number of respuff data items.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
Console. log (filter. FHIR ount())//Output 0

Returns

number

The number of respuff data items.


GetPoints

GetPoints(): McGePoint3dArray

Retrieve all point data from the respuff.

Example

ts

Returns

McGePoint3dArray


ItemDataDxf

ItemDataDxf(index): number

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

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
console.log(filter.ItemDataDxf(0))

Parameters

NameTypeDescription
Indexnumberindex value

Returns

number

DXF value


ItemDataType

ItemDataType(index): number

Retrieve the data type from the respuff data item.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
console.log(filter.ItemDataType(0))

Parameters

NameTypeDescription
Indexnumberindex value

Returns

number

Data type.


PrintData

PrintData(): void

Debugging input information

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
Filter. PrintData ("Debug Information")

Returns

void


Remove

Remove(lItem): void

Remove the respuff data item from the specified index.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AtLong (42);
filter.Remove(0);

Parameters

NameTypeDescription
ListNumberData item index

Returns

void


RemoveAll

RemoveAll(): void

Remove all respuff data items.

Example

ts
import { MxCADResbuf } from "mxcad"
//Define filters
const filter = new MxCADResbuf()
filter.AtLong (42);
filter.RemoveAll();

Returns

void


forEach

forEach(call): void

Traverse the data.

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

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


getImp

getImp(): any

Retrieve internal implementation objects.

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
let imp = obj.getImp();

Returns

any

Internal implementation object.

Inherited from

McRxObject.getImp


getJson

getJson(): string

Retrieve a string in JSON format.

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
const json = obj.getJson()

Returns

string

A string in JSON format.

Inherited from

McRxObject.getJson


initTempObject

initTempObject(imp): void

Initialize temporary objects.

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
obj.initTempObject()

Parameters

NameTypeDescription
'imp''any'Internal implementation object

Returns

void

Inherited from

McRxObject.initTempObject


isKindOf

isKindOf(sObjectName): boolean

Determine object type

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
let isKind = obj.isKindOf('SomeObjectType');
console.log(isKind); //  Output: True or false

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

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
console.log(obj.isNull()); //  Output: True or false

Returns

any

Inherited from

McRxObject.isNull


setJson

setJson(str): boolean

Set a string in JSON format.

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
const res = obj.setJson('{"key": "value"}');
console.log(res)

Parameters

NameTypeDescription
StrstringJSON formatted string

Returns

boolean

Is the setting successful.

Inherited from

McRxObject.setJson