[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McDbAttributeDefinition
Class: McDbAttributeDefinition
2d.McDbAttributeDefinition
Used to define attribute definitions for block properties, and provides methods to obtain and set various parameters of attributes
Hierarchy
↳
McDbAttributeDefinition
Table of contents
Constructors
Properties
Accessors
- alignmentPoint
- colorIndex
- drawOrder
- dxf0
- height
- horizontalMode
- isConstant
- isInvisible
- isPreset
- isVerifiable
- layer
- layerId
- linetype
- linetypeId
- linetypeScale
- lineweight
- normal
- objectName
- oblique
- position
- prompt
- rotation
- tag
- textString
- textStyle
- textStyleId
- trueColor
- verticalMode
- visible
- widthFactor
Methods
- IntersectWith
- adjustAlignment
- assertObjectModification
- clone
- createExtensionDictionary
- deleteXData
- disableDisplay
- erase
- explode
- getAllAppName
- getArea
- getBoundingBox
- getDatabase
- getDatabaseIndexId
- getExtensionDictionary
- getGripPoints
- getHandle
- getImp
- getJson
- getObjectID
- getOwnerID
- getxData
- getxDataDouble
- getxDataLong
- getxDataPoint
- getxDataString
- highlight
- initTempObject
- isErased
- isHaveExtensionDictionary
- isKindOf
- isNull
- mirror
- move
- moveGripPointsAt
- rotate
- scaleEntity
- setJson
- setxData
- setxDataDouble
- setxDataLong
- setxDataPoint
- setxDataString
- syncData
- transformBy
- unErase
- updateDisplay
Constructors
constructor
• new McDbAttributeDefinition(imp?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
imp? | Any | Implement object |
Overrides
Properties
imp
• imp: any = 0
Internal implementation object.
Inherited from
Accessors
alignmentPoint
• get alignmentPoint(): McGePoint3d
Get the alignment point of the text.
Example
//Assuming text is a valid text entity
const alignmentPoint = text.alignmentPoint;Returns
Inherited from
McDbText.alignmentPoint
• set alignmentPoint(pt): void
Set the alignment point of the text.
Example
import { McDbText, McGePoint3d } from "mxcad";
const text = new McDbText();
text.alignmentPoint = new McGePoint3d(0,0,0);
console.log(text.alignmentPoint)//(0,0,0)Parameters
| Name | Type | Description |
|---|---|---|
| Pt | McGePoint3d (2d. McGePoint3d. md) | 3D point vector |
Returns
void
Inherited from
McDbText.alignmentPoint
colorIndex
• get colorIndex(): number
Obtain object color index
Example
import { McDbEntity, ColorIndexType } from 'mxcad'
const ent = new McDbEntity();
ent.colorIndex = ColorIndexType.kByblock;
console.log(ent.colorIndex)Returns
number
Inherited from
McDbText.colorIndex
• set colorIndex(val): void
Set object color index
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | ColorIndexType |
Returns
void
Inherited from
McDbText.colorIndex
drawOrder
• get drawOrder(): number
Display order of objects
Example
//Assuming ent is a valid instance object
const order = ent.drawOrder();Returns
number
Inherited from
McDbText.drawOrder
• set drawOrder(order): void
Display order of objects
Example
import { MxCpp, MxCADSelectionSet } from "mxcad";
let ss = new MxCADSelectionSet();
If (! Await ss.userSelect) return;
//Obtain the maximum and minimum display order of objects on the current graph
let minmaxOrder = MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder();
//Place the object at the top.
let lOrder = minmaxOrder.maxDrawOrder + 1;
ss.forEach((id) => {
let ent = id.getMcDbEntity();
if (ent) {
ent.drawOrder = lOrder;
}
})Parameters
| Name | Type | Description |
|---|---|---|
| Order | number | sequential value |
Returns
void
Inherited from
McDbText.drawOrder
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
McDbText.dxf0
height
• get height(): number
Get the height of the text.
Example
//Assuming text is a valid text entity
const height = text.height;Returns
number
Inherited from
McDbText.height
• set height(val): void
Set text height
Example
import { McDbText } from "mxcad";
const text = new McDbText();
text.height = 20;
console.log(text.height)//20Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | height |
Returns
void
Inherited from
McDbText.height
horizontalMode
• get horizontalMode(): TextHorzMode
Obtain the horizontal alignment of the text.
Example
//Assuming text is a valid text entity
const horizontalMode = text.horizontalMode;Returns
Inherited from
McDbText.horizontalMode
• set horizontalMode(val): void
Set the horizontal alignment of text.
Example
import { McDbText, McDb } from "mxcad";
const text = new McDbText();
text.horizontalMode = McDb.TextHorzMode.kTextAlign;
console.log(text.horizontalMode)//3Parameters
| Name | Type | Description |
|---|---|---|
| Val | [TextHorzMode] (../enums/2d. McDb. TextHorzMode. md) | Horizontal alignment of text |
Returns
void
Inherited from
McDbText.horizontalMode
isConstant
• get isConstant(): boolean
Get whether the indicator property is a constant
Returns
boolean
• set isConstant(val): void
Set whether the indicator property is a constant
Example
import { McDbAttributeDefinition } from "mxcad";
const attribute = new McDbAttributeDefinition();
attribute.isConstant = true; // Set properties as constants
console.log(attribute.isConstant); // Obtain whether the attribute is a constantParameters
| Name | Type |
|---|---|
val | boolean |
Returns
void
isInvisible
• get isInvisible(): boolean
Get whether it is visible or not
Returns
boolean
• set isInvisible(val): void
Set whether it is visible
Example
import { McDbAttributeDefinition } from "mxcad";
const attribute = new McDbAttributeDefinition();
attribute.isInvisible = true; // Set attribute to invisible
attribute.isInvisible = false; // Set attribute to visible
console.log(attribute.isInvisible); // Obtain whether the attribute is visibleParameters
| Name | Type |
|---|---|
val | boolean |
Returns
void
isPreset
• get isPreset(): boolean
Get whether the attribute is preset
Returns
boolean
• set isPreset(val): void
Set whether the attribute is preset or not
Example
import { McDbAttributeDefinition } from "mxcad";
const attribute = new McDbAttributeDefinition();
attribute.isPreset = true; // Set attribute presets
console.log(attribute.isPreset); // Get whether the attribute is presetParameters
| Name | Type |
|---|---|
val | boolean |
Returns
void
isVerifiable
• get isVerifiable(): boolean
Is the attribute verifiable
Returns
boolean
• set isVerifiable(val): void
Is the property verifiable
Example
import { McDbAttributeDefinition } from "mxcad";
const attribute = new McDbAttributeDefinition();
attribute.isVerifiable = true; // Set properties for verification
console.log(attribute.isVerifiable); // Is the attribute verifiableParameters
| Name | Type |
|---|---|
val | boolean |
Returns
void
layer
• get layer(): string
Obtain the layer name of the object
Returns
string
Inherited from
McDbText.layer
• set layer(val): void
Set object layer name
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity();
ent.layer = "newLayerName";
console.log(ent.layer)Parameters
| Name | Type | Description |
|---|---|---|
| Val | string | Layer Name |
Returns
void
Inherited from
McDbText.layer
layerId
• get layerId(): McObjectId
Get layer ID object
Example
//Assuming ent is a valid instance object
const layerId = ent.layerId;Returns
Inherited from
McDbText.layerId
• set layerId(id): void
Set Layer Id Object
Example
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
Const layerId=mxcad. addLayer (Test Layer)
ent.layerId = layerId;Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Inherited from
McDbText.layerId
linetype
• get linetype(): string
Obtain the object line type name
Returns
string
Inherited from
McDbText.linetype
• set linetype(val): void
Set object line type name
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.linetype = "MyLineType";
console.log(ent.linetype)Parameters
| Name | Type | Description |
|---|---|---|
| Val | string | Line type name |
Returns
void
Inherited from
McDbText.linetype
linetypeId
• get linetypeId(): McObjectId
Get entity object line type ID
Example
//Assuming ent is a valid instance object
const linetypeId = ent.linetypeId;Returns
Inherited from
McDbText.linetypeId
• set linetypeId(id): void
Set entity object line type ID
Example
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
const lineId = mxcad.addLinetypeEx("TestMyLine", '25,-5');
ent.linetypeId = lineId;Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Inherited from
McDbText.linetypeId
linetypeScale
• get linetypeScale(): number
Obtain the proportion of object line types
Returns
number
Inherited from
McDbText.linetypeScale
• set linetypeScale(val): void
Set object line type scale
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.linetypeScale = 0.8;
console.log(ent.linetypeScale)Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | Line type ratio |
Returns
void
Inherited from
McDbText.linetypeScale
lineweight
• get lineweight(): number
Obtain object line weight
Returns
number
Inherited from
McDbText.lineweight
• set lineweight(val): void
Set object line weight
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.lineweight = 20;
console.log(ent.lineweight)Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | line weight |
Returns
void
Inherited from
McDbText.lineweight
normal
• get normal(): McGeVector3d
Return the normal of the object
Example
Returns
Inherited from
McDbText.normal
• set normal(val): void
Set the normal of the object
Example
Parameters
| Name | Type |
|---|---|
val | McGeVector3d |
Returns
void
Inherited from
McDbText.normal
objectName
• get objectName(): string
Get the object name.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
console.log(obj.objectName);Returns
string
Return object name
Inherited from
McDbText.objectName
oblique
• get oblique(): number
Obtain the tilt angle of the text.
Example
//Assuming text is a valid text entity
const oblique = text.oblique;Returns
number
Inherited from
McDbText.oblique
• set oblique(val): void
Set the tilt angle of the text.
Example
import { McDbText } from "mxcad";
const text = new McDbText();
text.oblique = Math.PI/4;
console.log(text.oblique)//45Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
Inherited from
McDbText.oblique
position
• get position(): McGePoint3d
Retrieve the location of the text.
Example
//Assuming text is a valid text entity
const position = text.position;Returns
Inherited from
McDbText.position
• set position(pt): void
Set the position of the text.
Example
import { McDbText, McGePoint3d } from "mxcad";
const text = new McDbText();
text.position = new McGePoint3d(0,0,0);
console.log(text.position)//(0,0,0)Parameters
| Name | Type | Description |
|---|---|---|
| Pt | McGePoint3d (2d. McGePoint3d. md) | 3D point vector |
Returns
void
Inherited from
McDbText.position
prompt
• get prompt(): string
When obtaining an inserted block instance, prompt the user to enter the text of the value
Returns
string
• set prompt(val): void
When setting the insertion block instance, prompt the user to enter the text of the value
Example
import { McDbAttributeDefinition } from "mxcad";
const attribute = new McDbAttributeDefinition();
attribute.prompt = "Enter value here"; // Prompt text for setting attributes
console.log(attribute.prompt); // Prompt text for obtaining attributesParameters
| Name | Type |
|---|---|
val | string |
Returns
void
rotation
• get rotation(): number
Get the rotation angle of the text.
Example
//Assuming text is a valid text entity
const rotation = text.rotation;Returns
number
Inherited from
McDbText.rotation
• set rotation(pt): void
Set the rotation angle of the text.
Example
import { McDbText } from "mxcad";
const text = new McDbText();
text.rotation = Math.PI/4;
console.log(text.rotation)//45Parameters
| Name | Type |
|---|---|
pt | number |
Returns
void
Inherited from
McDbText.rotation
tag
• get tag(): string
Retrieve a string of text.
Returns
string
• set tag(val): void
Set the string of text
Example
import { McDbAttributeDefinition } from "mxcad";
const attribute = new McDbAttributeDefinition();
attribute.tag = "TagName"; // Set attribute labels
console.log(attribute.tag); // Get attribute labelsParameters
| Name | Type |
|---|---|
val | string |
Returns
void
textString
• get textString(): string
Retrieve a string of text.
Example
//Assuming text is a valid text entity
const textString = text.textString;Returns
string
Inherited from
McDbText.textString
• set textString(val): void
Set the string of text.
Example
import { McDbText } from "mxcad";
const text = new McDbText();
Text.textString="Test Text";
Console. log (text. textString)//Test TextParameters
| Name | Type | Description |
|---|---|---|
| Val | string | string |
Returns
void
Inherited from
McDbText.textString
textStyle
• get textStyle(): string
Obtain the text style of the object
Returns
string
Inherited from
McDbText.textStyle
• set textStyle(val): void
Set object text style
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.textStyle = "st_style";Parameters
| Name | Type | Description |
|---|---|---|
| Val | string | Text style name |
Returns
void
Inherited from
McDbText.textStyle
textStyleId
• get textStyleId(): McObjectId
Get entity text style
Example
//Assuming ent is a valid instance object
const textStyleId = ent.textStyleId;Returns
Inherited from
McDbText.textStyleId
• set textStyleId(id): void
Set the text style of the entity
Example
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
const textStyleId = mxcad.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);
ent.textStyleId = textStyleId;Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Inherited from
McDbText.textStyleId
trueColor
• get trueColor(): McCmColor
Obtain the color of the object
Example
import { McDbEntity, McCmColor} from 'mxcad'
const ent = new McDbEntity();
ent.trueColor = new McCmColor(255, 0, 0);
console.log(ent.trueColor)Returns
Inherited from
McDbText.trueColor
• set trueColor(val): void
Set object color
Parameters
| Name | Type |
|---|---|
val | McCmColor |
Returns
void
Inherited from
McDbText.trueColor
verticalMode
• get verticalMode(): TextVertMode
Get the vertical alignment of the text.
Example
//Assuming text is a valid text entity
const verticalMode = text.verticalMode;Returns
Inherited from
McDbText.verticalMode
• set verticalMode(val): void
Set the vertical alignment of text.
Example
import { McDbText, McDb } from "mxcad";
const text = new McDbText();
text.verticalMode = McDb.TextVertMode.kTextVertMid;
console.log(text.verticalMode)//2Parameters
| Name | Type | Description |
|---|---|---|
| Val | [TextVertMode] (../enums/2d. McDb. TextVertMode. md) | Vertical alignment of text |
Returns
void
Inherited from
McDbText.verticalMode
visible
• get visible(): boolean
Is the object visible
Returns
boolean
Inherited from
McDbText.visible
• set visible(val): void
Set whether it is visible
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.visible = true;
console.log(ent.visible)Parameters
| Name | Type | Description |
|---|---|---|
| Val | boolean | Boolean value |
Returns
void
Inherited from
McDbText.visible
widthFactor
• get widthFactor(): number
Get the width factor of the text.
Example
//Assuming text is a valid text entity
const widthFactor = text.widthFactor;Returns
number
Inherited from
McDbText.widthFactor
• set widthFactor(val): void
Set the width factor of the text.
Example
import { McDbText } from "mxcad";
const text = new McDbText();
text.height = 0.8;
console.log(text.height)//0.8Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | width factor |
Returns
void
Inherited from
McDbText.widthFactor
Methods
IntersectWith
▸ IntersectWith(intersectObject, exOption): McGePoint3dArray
Intersection with other entities to obtain the intersection point
Example
import { McDbLine, McDb } from 'mxcad'
const line1 = new McDbLine(new McGePoint3d(0,0,0), new McGePoint3d(20,1,0));
const line2 = new McDbLine(new McGePoint3d(10,10,0), new McGePoint3d(11,1,0));
const ptArr = line1.IntersectWith(line2, McDb.Intersect.kExtendBoth)Parameters
| Name | Type | Description |
|---|---|---|
| IntersectObject | [McDbEntity] (2d. McDbEntity. md) | The entity object that needs to intersect is the entity object |
| ExOption | Intersection (../enums/2d. McDb. Intersect. md) | Intersection options |
Returns
Obtain all intersection points
Inherited from
adjustAlignment
▸ adjustAlignment(): void
Calculate the text position based on the current text alignment method and alignment point.
Example
Returns
void
Inherited from
assertObjectModification
▸ assertObjectModification(autoUndo?): number
Setting the state of the object to be changed can automatically trigger the update display function to update the display. For example, if the block table record is updated and the block reference needs to be notified to update the display, this function can be called.
Example
//Assuming obj is a database object
obj.assertObjectModification()Parameters
| Name | Type | Default value |
|---|---|---|
autoUndo | boolean | false |
Returns
number
Inherited from
McDbText.assertObjectModification
clone
▸ clone(): null | McDbObject
Clone objects.
Example
//Assuming obj is a database object
const obj_clone = obj.clone();Returns
null | McDbObject
The cloned object.
Inherited from
createExtensionDictionary
▸ createExtensionDictionary(): boolean
Create extended dictionary data for objects
Example
//Assuming obj is a database object
const res = obj.createExtensionDictionary();Returns
boolean
Inherited from
McDbText.createExtensionDictionary
deleteXData
▸ deleteXData(appName): boolean
Delete data related to entity specified application name
Example
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.deleteXData("DataName");
if(res){
//Delete successfully
}else
//Delete failed
}Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
boolean
Inherited from
disableDisplay
▸ disableDisplay(isDisable): void
Disable automatic update display of objects
Example
import { McDbLine } from 'mxcad'
const line1 = new McDbLine(new McGePoint3d(0,0,0), new McGePoint3d(20,1,0));
line1.disableDisplay(true)Parameters
| Name | Type | Description |
|---|---|---|
| IsDisable | boolean | Do you want to disable automatic object update display |
Returns
void
Inherited from
erase
▸ erase(): boolean
Delete object.
Example
//Assuming obj is a database object
const res = obj.erase();
console.log(res);Returns
boolean
Whether the deletion was successful.
Inherited from
explode
▸ explode(): MxCADResbuf
Break the object and return the linked list of the object's data after being broken
Example
import { McDbEntity, MxCADResbuf } from "mxcad";
//Obtain the target object
let getEnt = new MxCADUiPrEntity();
GetEnt.setMessage ("Select object to break: ");
let id = await getEnt.go();
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
//Smash objects
let retExplode: MxCADResbuf = ent.explode();
if (retExplode.GetCount() == 0) return;
let iExplodeConut = retExplode.GetCount();
for (let j = 0; j < iExplodeConut; j++) {
let tmpobj = retExplode.AtObject(j).val;
if(tmpobj instanceof McDbEntity ){
mxcad.drawEntity(tmpobj);
}
}Returns
Rebuf data
Inherited from
getAllAppName
▸ getAllAppName(): McGeStringArray
Get the application name (AppName) of all XData records contained in the entity
Example
//Assuming ent is a valid instance object
const appNames = ent.getAllAppName();
console.log(appNames);Returns
Inherited from
getArea
▸ getArea(): Object
Calculate Area
Example
import { McGePoint3d, McDbCircle } from "mxcad"
const center = new McGePoint3d(0,0,0);
const circle = new McDbCircle(center, 20);
const area = circle.getArea();
Console.log ("Circle area: ", area)Returns
Object
Is the val area value | ret successfully obtained
| Name | Type |
|---|---|
ret | boolean |
val | number |
Inherited from
getBoundingBox
▸ getBoundingBox(): Object
Obtain the minimum outsourcing of the object
Example
import { McDbText, McGePoint3d } from 'mxcad'
const text = new McDbText();
Text.textString="Test Test";
text.height = 20;
text.position = text.alignmentPoint = new McGePoint3d(0,0,0);
const { minPt, maxPt, ret } = text.getBoundingBox()Returns
Object
| Name | Type |
|---|---|
maxPt | McGePoint3d |
minPt | McGePoint3d |
ret | boolean |
Inherited from
getDatabase
▸ getDatabase(): McDbDatabase
Get the database where the object is located
Example
//Assuming obj is a database object
const data = obj.getDatabase();Returns
Return to database
Inherited from
getDatabaseIndexId
▸ getDatabaseIndexId(): number
Get the index ID of the object
Example
//Assuming obj is a database object
const id = obj.getDatabaseIndexId();Returns
number
Inherited from
getExtensionDictionary
▸ getExtensionDictionary(): McDbDictionary
Obtain the extended dictionary data of the object
Example
//Assuming obj is a database object
const id = obj.getOwnerID();Returns
Expand dictionary data
Inherited from
McDbText.getExtensionDictionary
getGripPoints
▸ getGripPoints(): McGePoint3dArray
Get the control points of the object
Example
//Assuming obj is a database object
const ptArr = obj.getGripPoints();Returns
Inherited from
getHandle
▸ getHandle(): string
Obtain object handle
Example
//Assuming obj is a database object
const handle = obj.getHandle();Returns
string
Return object handle
Inherited from
getImp
▸ getImp(): any
Retrieve internal implementation objects.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
let imp = obj.getImp();Returns
any
Internal implementation object.
Inherited from
getJson
▸ getJson(): string
Retrieve a string in JSON format.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
const json = obj.getJson()Returns
string
A string in JSON format.
Inherited from
getObjectID
▸ getObjectID(): McObjectId
Get the object ID.
Example
import { McDbObject } from "mxcad";
const id = obj.getObjectID();Returns
Object ID.
Inherited from
getOwnerID
▸ getOwnerID(): number
Obtain the ID of the object owner
Example
//Assuming obj is a database object
const id = obj.getOwnerID();Returns
number
Inherited from
getxData
▸ getxData(appName?): MxCADResbuf
Obtain the extended data of the object
Example
//Assuming ent is a valid instance object
const xData = ent.getXData();Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AppName | string | "" | Extended Data Name |
Returns
Inherited from
getxDataDouble
▸ getxDataDouble(appName): Object
Retrieve the double value from the specified XData type of the entity
Example
//Assuming ent is a valid instance object
let data = ent.getxDataDouble("DataName");
if(data.ret){
console.log(data.val)
}Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
Object
Double value
| Name | Type |
|---|---|
ret | boolean |
val | number |
Inherited from
getxDataLong
▸ getxDataLong(appName): Object
Retrieve the long (integer) value from the specified XData type of the entity
Example
//Assuming ent is a valid instance object
let data = ent.getxDataLong("DataName");
if(data.ret){
console.log(data.val)
}Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
Object
Long value
| Name | Type |
|---|---|
ret | boolean |
val | number |
Inherited from
getxDataPoint
▸ getxDataPoint(appName): Object
Retrieve point objects from the specified XData type of entity
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
Object
Obtain results and 3D point objects
| Name | Type |
|---|---|
ret | boolean |
val | McGePoint3d |
Inherited from
getxDataString
▸ getxDataString(appName): Object
Retrieve XData information associated with a specific entity and return it in string form
Example
//Assuming ent is a valid instance object
let data = ent.getxDataString("DataName");
if(data.ret){
console.log(data.val)
}Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
Object
Val XData information | whether ret returns success
| Name | Type |
|---|---|
ret | boolean |
val | string |
Inherited from
highlight
▸ highlight(isHighlight): void
Set whether the object is highlighted
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.highlight(true);Parameters
| Name | Type | Description |
|---|---|---|
| IsHighlight | boolean | Is it highlighted |
Returns
void
Inherited from
initTempObject
▸ initTempObject(imp): void
Initialize temporary objects.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
obj.initTempObject()Parameters
| Name | Type | Description |
|---|---|---|
| 'imp' | 'any' | Internal implementation object |
Returns
void
Inherited from
isErased
▸ isErased(): boolean
Has the object been deleted
Example
//Assuming obj is a database object
const res = obj.isErased();
console.log(res);Returns
boolean
Inherited from
isHaveExtensionDictionary
▸ isHaveExtensionDictionary(): boolean
Is there any extended dictionary data available
Example
//Assuming obj is a database object
const res = obj.isHaveExtensionDictionary();Returns
boolean
Inherited from
McDbText.isHaveExtensionDictionary
isKindOf
▸ isKindOf(sObjectName): boolean
Determine object type
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
let isKind = obj.isKindOf('SomeObjectType');
console.log(isKind); // Output: True or falseParameters
| 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
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
console.log(obj.isNull()); // Output: True or falseReturns
any
Inherited from
mirror
▸ mirror(point1, point2): boolean
Mirror oriented object
Example
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.mirror(new McGePoint3d(0,0,0), new McGePoint3d(20,10,0))Parameters
| Name | Type | Description |
|---|---|---|
| Point1 | [McGePoint3d] (2d. McGePoint3d. md) | Mirror Base Point |
point2 | McGePoint3d | - |
Returns
boolean
Inherited from
move
▸ move(fromPoint, toPoint): boolean
move objects
Example
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.move(new McGePoint3d(0,0,0), new McGePoint3d(20,0,0))Parameters
| Name | Type | Description |
|---|---|---|
| From Point | [McGePoint3d] (2d. McGePoint3d. md) | Move the starting point |
| ToPoint | [McGePoint3d] (2d. McGePoint3d. md) | Move End Point |
Returns
boolean
Inherited from
moveGripPointsAt
▸ moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset): any
Control points for moving objects
Example
//Assuming obj is a database object
obj.moveGripPointsAt(1,10,10,10);Parameters
| Name | Type | Description |
|---|---|---|
| IIndex | Number | Index |
| DXOffset | number | X-axis offset |
| DYOffset | number | Y-axis offset |
| DZOffset | number | Z-axis offset |
Returns
any
Inherited from
rotate
▸ rotate(basePoint, dRotationAngle): boolean
Rotate object
Example
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.rotate(new McGePoint3d(0,0,0), Math.PI)Parameters
| Name | Type | Description |
|---|---|---|
| BasePoint | [McGePoint3d] (2d. McGePoint3d. md) | Rotate the base point |
| DRotationAngle | number | Rotation angle |
Returns
boolean
Inherited from
scaleEntity
▸ scaleEntity(basePoint, dScaleFactor): boolean
Scaling objects
Example
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.scaleEntity(new McGePoint3d(0,0,0), 0.5)Parameters
| Name | Type | Description |
|---|---|---|
| BasePoint | [McGePoint3d] (2d. McGePoint3d. md) | Scale Base Point |
| DScaleFactor | number | scaling factor (<1 zoom out;>1 zoom in) |
Returns
boolean
Inherited from
setJson
▸ setJson(str): boolean
Set a string in JSON format.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
const res = obj.setJson('{"key": "value"}');
console.log(res)Parameters
| Name | Type | Description |
|---|---|---|
| Str | string | JSON formatted string |
Returns
boolean
Is the setting successful.
Inherited from
setxData
▸ setxData(xdata): boolean
Set extended data for objects
Example
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
//Set extended data
let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
ent.setxData(new MxCADResbuf([{type:DxfCode.kExDataName,val:"DataName"},{type:DxfCode.kString,val:"yyyyy"}]));Parameters
| Name | Type | Description |
|---|---|---|
| Xdata | [MxCADResbuf] (2d. MxCADResbuf. md) | Extended data linked list |
Returns
boolean
Inherited from
setxDataDouble
▸ setxDataDouble(appName, val): boolean
Set the double value in the specified XData type of the entity
Example
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.setxDataDouble("DataName", 0);
if(res){
//Setting successful
}else{
//Setting failed
}Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | number | double value |
Returns
boolean
Boolean value
Inherited from
setxDataLong
▸ setxDataLong(appName, val): boolean
Set the long (integer) value in the specified XData type of the entity
Example
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.setxDataLong("DataName", 123456);
if(res){
//Setting successful
}else{
//Setting failed
}Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | number | long value |
Returns
boolean
Long value
Inherited from
setxDataPoint
▸ setxDataPoint(appName, val): boolean
Set the point object in the specified XData type of the entity
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | [McGePoint3d] (2d. McGePoint3d. md) | Point Object |
Returns
boolean
Obtain results and 3D point objects
Inherited from
setxDataString
▸ setxDataString(appName, val): boolean
Set XData information associated with a specific entity and set it in string form
Example
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.setxDataString("DataName", "xxxxx");
if(res){
//Setting successful
}else{
//Setting failed
}Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | string | string value |
Returns
boolean
Is the setting successful
Inherited from
syncData
▸ syncData(_toCpp?): boolean
Synchronize entity data. This method may be called after modifying the entity's attributes or attaching new data to ensure that all changes are correctly saved to the entity's database records.
Example
//Assuming ent is a valid instance object
const res = ent.syncData(true);
if(res){
//Synchronization successful
}else{
//Synchronization failed
}Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| _toCpp | boolean | true | Whether to synchronize data |
Returns
boolean
Inherited from
transformBy
▸ transformBy(transformationMatrix): boolean
Transform object
Example
import { McGeMatrix3d, McDbEntity, McGeVector3d} from 'mxcad'
const ent = new McDbEntity()
let matrix = new McGeMatrix3d();
matrix.setToTranslation(new McGeVector3d(20,0,0));// translation
ent.transformBy(matrix);Parameters
| Name | Type | Description |
|---|---|---|
| TransformationMatrix | [McGeMatrix3d] (2d. McGeMatrix3d. md) | Transformation Matrix |
Returns
boolean
Inherited from
unErase
▸ unErase(): boolean
Anti delete object.
Example
//Assuming obj is a database object
const res = obj.unErase();
console.log(res);Returns
boolean
Inherited from
updateDisplay
▸ updateDisplay(): void
Display the updated display of the calling object
Example
//Assuming ent is a valid instance object
ent.updateDisplay()Returns
void
