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.

Parameters

NameTypeDescription
imp?AnyInternal implementation object

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

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

Example

ts
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

NameTypeDefault value
strstringundefined
decodeFromGb2312booleantrue

Returns

number


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.

Example

ts
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

NameTypeDefault valueDescription
Valnumberundefinedlong type value
LDataTypenumber-10data type

Returns

number

Index of added data items.

Example

ts
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

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 filters
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

Example

ts
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

NameTypeDefault valueDescription
valnumberundefinedObjectId。
LDataTypenumber-10data type

Returns

number

Index of added data items.

Example

ts
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

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

Returns

number

Index of added data items.

Example

ts
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

NameTypeDefault valueDescription
Strstringundefinedstring
LDataTypenumber-10data type
decodeFromGb2312booleantrue-

Returns

number

Index of added data items.

Example

ts
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

NameTypeDescription
ListNumberData item index

Returns

Object

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

NameType
retboolean
valnumber

Example

ts
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

NameTypeDescription
ListNumberData item index

Returns

Object

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

NameType
retboolean
valnumber

Example

ts
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

NameTypeDescription
ListNumberData item index

Returns

Object

An object that contains database objects and return values.

NameType
retboolean
valundefined | McDbObject

Example

ts
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

NameTypeDescription
ListNumberData item index

Returns

Object

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

NameType
retboolean
valMcObjectId

Example

ts
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

NameTypeDescription
ListNumberData item index

Returns

Object

An object that contains point coordinates and return values.

NameType
retboolean
valMcGePoint3d

Example

ts
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

NameTypeDefault valueDescription
Listnumberundefineddata item index
decodeFromGb2312booleantrue-

Returns

Object

An object that contains a string and a return value.

NameType
retboolean
valstring

Example

ts
import { MxCADResbuf } from "mxcad

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

Clear

Clear(): void

Clear the respuff data.

Returns

void

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

GetCount

GetCount(): number

Retrieve the number of respuff data items.

Returns

number

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

GetPoints

GetPoints(): McGePoint3dArray

Retrieve all point data from the respuff.

Returns

McGePoint3dArray

Example

ts

ItemDataDxf

ItemDataDxf(index): number

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

Parameters

NameTypeDescription
Indexnumberindex value

Returns

number

DXF value

Example

ts
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

NameTypeDescription
Indexnumberindex value

Returns

number

Data type.

Example

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

PrintData

PrintData(): void

Debugging input information

Returns

void

Example

ts
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

NameTypeDescription
ListNumberData item index

Returns

void

Example

ts
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

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

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.

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McRxObject.getImp


getJson

getJson(): string

Retrieve a string in JSON format.

Returns

string

A string in JSON format.

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McRxObject.getJson


initTempObject

initTempObject(imp): void

Initialize temporary objects.

Parameters

NameTypeDescription
'imp''any'Internal implementation object

Returns

void

Example

ts
import { McRxObject } from 'mxcad';

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

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

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McRxObject.isKindOf


isNull

isNull(): any

Determine if it is an empty object

Returns

any

Example

ts
import { McRxObject } from 'mxcad';

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

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.

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McRxObject.setJson