[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McDbRay
Class: McDbRay
2d.McDbRay
McDbRay is a ray object class used to create rays that extend from a base point in a specified direction.
Description
This class is used to represent a ray in CAD and is commonly used to assist in locating, measuring, and constructing geometric relationships.
Summary of usage:
- First, create an instance of McDbRay.
- Set its base point and direction vector again.
- Finally, draw the ray into the current space.
Example
import { McDbRay, McGePoint3d, McGeVector3d, MxCpp } from "mxcad";
const ray = new McDbRay();
ray.basePoint = new McGePoint3d(0, 0, 0);
ray.unitDir = new McGeVector3d(1, 0, 0);
MxCpp.getCurrentMxCAD().drawEntity(ray);Hierarchy
↳
McDbRay
Table of contents
Constructors
Properties
Accessors
- basePoint
- colorIndex
- drawOrder
- dxf0
- layer
- layerId
- linetype
- linetypeId
- linetypeScale
- lineweight
- normal
- objectName
- textStyle
- textStyleId
- thickness
- trueColor
- unitDir
- visible
Methods
- IntersectWith
- assertObjectModification
- clone
- createExtensionDictionary
- deleteXData
- disableDisplay
- erase
- explode
- getAllAppName
- getArea
- getBoundingBox
- getClosestPointTo
- getDatabase
- getDatabaseIndexId
- getDistAtParam
- getDistAtPoint
- getEndParam
- getEndPoint
- getExtensionDictionary
- getFirstDeriv
- getFirstDerivFromParam
- getGripEditBasePointsIndex
- getGripPoints
- getHandle
- getImp
- getJson
- getLength
- getObjectID
- getOwnerID
- getParamAtDist
- getParamAtPoint
- getPointAtDist
- getPointAtParam
- getSamplePoints
- getStartParam
- getStartPoint
- getxData
- getxDataDouble
- getxDataLong
- getxDataPoint
- getxDataString
- highlight
- initTempObject
- isErased
- isHaveExtensionDictionary
- isKindOf
- isNull
- mirror
- move
- moveGripPointsAt
- offsetCurves
- rotate
- scaleEntity
- setBasePoint
- setJson
- setUnitDir
- setxData
- setxDataDouble
- setxDataLong
- setxDataPoint
- setxDataString
- splitCurves
- splitCurvesFromParam
- syncData
- transformBy
- unErase
- updateDisplay
Constructors
constructor
• new McDbRay(imp?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
imp? | Any | Internal object |
Overrides
Properties
imp
• imp: any = 0
Internal implementation object.
Inherited from
Accessors
basePoint
• get basePoint(): McGePoint3d
Obtain point coordinates.
Returns
• set basePoint(pt): void
Set point coordinates.
Parameters
| Name | Type |
|---|---|
pt | McGePoint3d |
Returns
void
colorIndex
• get colorIndex(): number
Obtain object color index
Returns
number
Inherited from
McDbCurve.colorIndex
• set colorIndex(val): void
Set object color index
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | ColorIndexType |
Returns
void
Inherited from
McDbCurve.colorIndex
drawOrder
• get drawOrder(): number
Display order of objects
Returns
number
Inherited from
McDbCurve.drawOrder
• set drawOrder(order): void
Display order of objects
Parameters
| Name | Type | Description |
|---|---|---|
| Order | number | sequential value |
Returns
void
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;
}
})Inherited from
McDbCurve.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
McDbCurve.dxf0
layer
• get layer(): string
Obtain the layer name of the object
Returns
string
Inherited from
McDbCurve.layer
• set layer(val): void
Set object layer name
Parameters
| Name | Type | Description |
|---|---|---|
| Val | string | Layer Name |
Returns
void
Inherited from
McDbCurve.layer
layerId
• get layerId(): McObjectId
Get layer ID object
Returns
Inherited from
McDbCurve.layerId
• set layerId(id): void
Set Layer Id Object
Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Inherited from
McDbCurve.layerId
linetype
• get linetype(): string
Obtain the object line type name
Returns
string
Inherited from
McDbCurve.linetype
• set linetype(val): void
Set object line type name
Parameters
| Name | Type | Description |
|---|---|---|
| Val | string | Line type name |
Returns
void
Inherited from
McDbCurve.linetype
linetypeId
• get linetypeId(): McObjectId
Get entity object line type ID
Returns
Inherited from
McDbCurve.linetypeId
• set linetypeId(id): void
Set entity object line type ID
Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Inherited from
McDbCurve.linetypeId
linetypeScale
• get linetypeScale(): number
Obtain the proportion of object line types
Returns
number
Inherited from
McDbCurve.linetypeScale
• set linetypeScale(val): void
Set object line type scale
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | Line type ratio |
Returns
void
Inherited from
McDbCurve.linetypeScale
lineweight
• get lineweight(): number
Obtain object line weight
Returns
number
Inherited from
McDbCurve.lineweight
• set lineweight(val): void
Set object line weight
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | line weight |
Returns
void
Inherited from
McDbCurve.lineweight
normal
• get normal(): McGeVector3d
Return the normal of the object
Returns
Inherited from
McDbCurve.normal
• set normal(val): void
Set the normal of the object
Parameters
| Name | Type |
|---|---|
val | McGeVector3d |
Returns
void
Inherited from
McDbCurve.normal
objectName
• get objectName(): string
Get the object name.
Returns
string
Return object name
Inherited from
McDbCurve.objectName
textStyle
• get textStyle(): string
Obtain the text style of the object
Returns
string
Inherited from
McDbCurve.textStyle
• set textStyle(val): void
Set object text style
Parameters
| Name | Type | Description |
|---|---|---|
| Val | string | Text style name |
Returns
void
Inherited from
McDbCurve.textStyle
textStyleId
• get textStyleId(): McObjectId
Get entity text style
Returns
Inherited from
McDbCurve.textStyleId
• set textStyleId(id): void
Set the text style of the entity
Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
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 mxcad = MxCpp.getCurrentMxCAD();
const textStyleId = mxcad.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);
ent.textStyleId = textStyleId;Inherited from
McDbCurve.textStyleId
thickness
• get thickness(): number
Obtain the thickness of the object
Returns
number
Inherited from
McDbCurve.thickness
• set thickness(val): void
Set object thickness
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
Inherited from
McDbCurve.thickness
trueColor
• get trueColor(): McCmColor
Obtain the color of the object
Returns
Inherited from
McDbCurve.trueColor
• set trueColor(val): void
Set object color
Parameters
| Name | Type |
|---|---|
val | McCmColor |
Returns
void
Inherited from
McDbCurve.trueColor
unitDir
• get unitDir(): McGeVector3d
Obtain the direction vector of the ray.
Returns
• set unitDir(vec): void
Set the direction vector of the ray
Parameters
| Name | Type |
|---|---|
vec | McGeVector3d |
Returns
void
visible
• get visible(): boolean
Is the object visible
Returns
boolean
Inherited from
McDbCurve.visible
• set visible(val): void
Set whether it is visible
Parameters
| Name | Type | Description |
|---|---|---|
| Val | boolean | Boolean value |
Returns
void
Inherited from
McDbCurve.visible
Methods
IntersectWith
▸ IntersectWith(intersectObject, exOption): McGePoint3dArray
Intersection with other entities to obtain the intersection point
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
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)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.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AutoUndo | boolean | false | Should this modification automatically support undo? Default is false |
Returns
number
Inherited from
McDbCurve.assertObjectModification
clone
▸ clone(): null | McDbObject
Clone objects.
Returns
null | McDbObject
The cloned object.
Inherited from
createExtensionDictionary
▸ createExtensionDictionary(): boolean
Create extended dictionary data for objects
Returns
boolean
Inherited from
McDbCurve.createExtensionDictionary
deleteXData
▸ deleteXData(appName): boolean
Delete data related to entity specified application name
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
boolean
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
}Inherited from
disableDisplay
▸ disableDisplay(isDisable): void
Disable automatic update display of objects
Parameters
| Name | Type | Description |
|---|---|---|
| IsDisable | boolean | Do you want to disable automatic object update display |
Returns
void
Inherited from
erase
▸ erase(): boolean
Delete object.
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
Returns
Rebuf data
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);
}
}Inherited from
getAllAppName
▸ getAllAppName(): McGeStringArray
Get the application name (AppName) of all XData records contained in the entity
Returns
Inherited from
getArea
▸ getArea(): Object
Calculate Area
Returns
Object
Is the val area value | ret successfully obtained
| Name | Type |
|---|---|
ret | boolean |
val | number |
Example
import { McGePoint3d, McDbCircle } from "mxcad"
const circle = new McDbCircle(0,0,0, 20);
const area = circle.getArea();
Console.log ("Circle area: ", area)Inherited from
getBoundingBox
▸ getBoundingBox(): Object
Obtain the minimum outsourcing of the object
Returns
Object
| Name | Type |
|---|---|
maxPt | McGePoint3d |
minPt | McGePoint3d |
ret | boolean |
Inherited from
getClosestPointTo
▸ getClosestPointTo(givenPnt, isExtend): Object
Obtain the closest point from a point to the curve
Parameters
| Name | Type | Description |
|---|---|---|
| GivenPnt | [McGePoint3d] (2d. McGePoint3d. md) | Reference Point |
| IsExtend | boolean | Whether to extend entity |
Returns
Object
Point objects and execution results.
| Name | Type |
|---|---|
ret | boolean |
val | McGePoint3d |
Example
import { McGePoint3d, McDbCircle, MxCADUiPrPoint, MxCpp } from "mxcad"
const circle = new McDbCircle(0,0,0, 20);
const mxcad = MxCpp.getCurrentMxCAD();
mxcad.drawEntity(circle);
const getPoint = new MxCADUiPrPoint();
getPoint.setUserDraw((pt,pw)=>{
//Get pt to the nearest point on the circle
const point = circle.getClosestPointTo(pt);
console.log(point)
})
const point = await getPoint.go();Inherited from
getDatabase
▸ getDatabase(): McDbDatabase
Get the database where the object is located
Returns
Return to database
Inherited from
getDatabaseIndexId
▸ getDatabaseIndexId(): number
Get the index ID of the object
Returns
number
Inherited from
getDistAtParam
▸ getDistAtParam(param): Object
Get the distance at the parameter location.
Parameters
| Name | Type | Description |
|---|---|---|
| Parameter position: |
Returns
Object
Distance and execution results.
| Name | Type |
|---|---|
ret | boolean |
val | number |
Inherited from
getDistAtPoint
▸ getDistAtPoint(pt): Object
Obtain the distance and position of points on the curve.
Parameters
| Name | Type | Description |
|---|---|---|
| Pt | [McGePoint3d] (2d. McGePoint3d. md) | Distance position |
Returns
Object
Points and execution results.
| Name | Type |
|---|---|
ret | boolean |
val | number |
Example
import { McGePoint3d, McDbLine } from "mxcad"
const pt1 = new McGePoint3d(0,0,0);
const pt2 = new McGePoint3d(20,0,0);
const line = new McDbLine(pt1, pt2)
const res = line.getDistAtPoint(pt2);
if(res.ret){
const dist = res.val;
console.log(dist);//20
}Inherited from
getEndParam
▸ getEndParam(): Object
Get the end parameter.
Returns
Object
End parameters and execution results.
| Name | Type |
|---|---|
ret | boolean |
val | number |
Inherited from
getEndPoint
▸ getEndPoint(): Object
Obtain the endpoint of the curve
Returns
Object
The endpoint and execution result of the curve.
| Name | Type |
|---|---|
ret | boolean |
val | McGePoint3d |
Example
import { McGePoint3d, McDbLine } from "mxcad"
const pt1 = new McGePoint3d(0,0,0);
const pt2 = new McGePoint3d(20,0,0);
const line = new McDbLine(pt1, pt2)
const res = line.getEndPoint();
if(res.ret){
const point = res.val;
console.log(point);//(20, 0, 0)
}Inherited from
getExtensionDictionary
▸ getExtensionDictionary(): McDbDictionary
Obtain the extended dictionary data of the object
Returns
Expand dictionary data
Inherited from
McDbCurve.getExtensionDictionary
getFirstDeriv
▸ getFirstDeriv(pt): Object
Obtain the first derivative of the curve through a certain point on the curve
Parameters
| Name | Type | Description |
|---|---|---|
| Pt | [McGePoint3d] (2d. McGePoint3d. md) | Points on the curve |
Returns
Object
The first derivative of the curve and its execution result.
| Name | Type |
|---|---|
ret | boolean |
val | McGeVector3d |
Example
import { McGePoint3d, McDbCircle } from "mxcad"
const circle = new McDbCircle(0,0,0, 20);
const vec = circle.getFirstDeriv(new McGePoint3d(20,0,0));// Target point tangent vector
if(vec.ret){
const val = vec.val;
}Inherited from
getFirstDerivFromParam
▸ getFirstDerivFromParam(param): Object
Obtain the first derivative of the curve through curve parameters
Parameters
| Name | Type | Description |
|---|---|---|
| Param | number | curve parameters |
Returns
Object
The first derivative of the curve and its execution result.
| Name | Type |
|---|---|
ret | boolean |
val | McGeVector3d |
Inherited from
McDbCurve.getFirstDerivFromParam
getGripEditBasePointsIndex
▸ getGripEditBasePointsIndex(): number[]
Retrieve the edit base point index corresponding to the grip of the object.
Returns
number[]
Inherited from
McDbCurve.getGripEditBasePointsIndex
getGripPoints
▸ getGripPoints(): McGePoint3dArray
Get the grip array of the object
Returns
Inherited from
getHandle
▸ getHandle(): string
Obtain object handle
Returns
string
Return object handle
Inherited from
getImp
▸ 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
getLength
▸ getLength(): Object
Obtain the length of the curve
Returns
Object
| Name | Type |
|---|---|
ret | boolean |
val | number |
Example
import { MxCpp, MxCADResbuf, MxCADUtility, MxCADUiPrPoint} from "mxcad"
const mxcad = MxCpp.App.getCurrentMxCAD();
let filter = new MxCADResbuf();
filter.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE,ELLIPSE");
Let aryId=await MxCADUtility. userSelect ("Select target curve", filter);
if (aryId.length == 0) return;
aryId.forEach(async (id) => {
let event = id.getMcDbEntity() as McDbCurve;
let length = event.getLength().val;
console.log(length)
});Inherited from
getObjectID
▸ getObjectID(): McObjectId
Get the object ID.
Returns
Object ID.
Inherited from
getOwnerID
▸ getOwnerID(): number
Obtain the ID of the object owner
Returns
number
Inherited from
getParamAtDist
▸ getParamAtDist(dist): Object
Obtain parameters at the distance position.
Parameters
| Name | Type | Description |
|---|---|---|
| Dist | Number | Distance Position |
Returns
Object
Parameters and execution results.
| Name | Type |
|---|---|
ret | boolean |
val | number |
Inherited from
getParamAtPoint
▸ getParamAtPoint(pt): Object
Obtain the curve parameters at a certain point on the curve
Parameters
| Name | Type | Description |
|---|---|---|
| Pt | [McGePoint3d] (2d. McGePoint3d. md) | Points on the curve |
Returns
Object
Curve parameters and execution results.
| Name | Type |
|---|---|
ret | boolean |
val | number |
Inherited from
getPointAtDist
▸ getPointAtDist(dist): Object
Obtain the point at the distance position.
Parameters
| Name | Type | Description |
|---|---|---|
| Dist | Number | Distance Position |
Returns
Object
Points and execution results.
| Name | Type |
|---|---|
ret | boolean |
val | McGePoint3d |
Example
import { McGePoint3d, McDbLine } from "mxcad"
const pt1 = new McGePoint3d(0,0,0);
const pt2 = new McGePoint3d(20,0,0);
const line = new McDbLine(pt1, pt2)
const res = line.getPointAtDist(10);
if(res.ret){
const point = res.val;
console.log(point);//(10, 0, 0)
}Inherited from
getPointAtParam
▸ getPointAtParam(param): Object
Obtain the coordinates of the point where the curve parameters are located
Parameters
| Name | Type | Description |
|---|---|---|
| Param | number | curve parameters |
Returns
Object
Point objects and execution results.
| Name | Type |
|---|---|
ret | boolean |
val | McGePoint3d |
Inherited from
getSamplePoints
▸ getSamplePoints(dApproxEps?): MxCADResbuf
Discretize the curve into a pile of points
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| DApproxEps | number | 0.0001 | sampling interval |
Returns
Rebuf data
Inherited from
getStartParam
▸ getStartParam(): Object
Get the starting parameters.
Returns
Object
Initial parameters and execution results.
| Name | Type |
|---|---|
ret | boolean |
val | number |
Inherited from
getStartPoint
▸ getStartPoint(): Object
Obtain the starting point of the curve
Returns
Object
The starting point and execution result of the curve.
| Name | Type |
|---|---|
ret | boolean |
val | McGePoint3d |
Example
import { McGePoint3d, McDbLine } from "mxcad"
const pt1 = new McGePoint3d(0,0,0);
const pt2 = new McGePoint3d(20,0,0);
const line = new McDbLine(pt1, pt2)
const res = line.getStartPoint();
if(res.ret){
const point = res.val;
console.log(point);//(0, 0, 0)
}Inherited from
getxData
▸ getxData(appName?): MxCADResbuf
Obtain the extended data of the object
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
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
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
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
Parameters
| Name | Type | Description |
|---|---|---|
| IsHighlight | boolean | Is it highlighted |
Returns
void
Inherited from
initTempObject
▸ initTempObject(imp): void
Initialize temporary objects.
Parameters
| Name | Type | Description |
|---|---|---|
| 'imp' | 'any' | Internal implementation object |
Returns
void
Inherited from
isErased
▸ isErased(): boolean
Has the object been deleted
Returns
boolean
Inherited from
isHaveExtensionDictionary
▸ isHaveExtensionDictionary(): boolean
Is there any extended dictionary data available
Returns
boolean
Inherited from
McDbCurve.isHaveExtensionDictionary
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
mirror
▸ mirror(point1, point2): boolean
Mirror oriented object
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
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
Grips for moving objects
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
offsetCurves
▸ offsetCurves(dOffsetDist, ptOffsetRef): McDbObjectArray
Obtain offset curve
Parameters
| Name | Type | Description |
|---|---|---|
| DOffsetDist | number | offset distance |
| PtOffsetRef | [McGePoint3d] (2d. McGePoint3d. md) | Offset point |
Returns
Offset object array.
Example
import { MxCADUiPrPoint, MxCpp } from 'mxcad'
let getFristPoint = new MxCADUiPrPoint();
let offsetDist = 10 ;
let getEvent = new MxCADUiPrEntity();
GetEvent.setMessage ('Specify offset object ');
let event_id = await getEvent.go();
if (!event_id) return;
let event = (await event_id.getMcDbEntity()) as McDbCurve;
let getoOffPt = new MxCADUiPrPoint();
GetoOffPt.setMessage ('specify offset point ');
let offPt = await getoOffPt.go();
if (!offPt) return;
let objArr = event.offsetCurves(offsetDist, offPt);
if (objArr.length() === 0) return;
objArr.forEach((obj: McDbObject) => {
MxCpp.getCurrentCAD().drawEntity(obj as McDbEntity);
});Inherited from
rotate
▸ rotate(basePoint, dRotationAngle): boolean
Rotate object
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
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
setBasePoint
▸ setBasePoint(x, y, z?): void
Set point coordinates.
Parameters
| Name | Type | Description |
|---|---|---|
| X | number | X coordinate |
| Y | number | Y coordinate |
z? | Number | Z coordinate |
Returns
void
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.
Inherited from
setUnitDir
▸ setUnitDir(x, y, z?): void
Set the direction vector of the ray
Parameters
| Name | Type | Description |
|---|---|---|
| X | number | X coordinate |
| Y | number | Y coordinate |
z? | Number | Z coordinate |
Returns
void
setxData
▸ setxData(xdata): boolean
Set extended data for objects
Parameters
| Name | Type | Description |
|---|---|---|
| Xdata | [MxCADResbuf] (2d. MxCADResbuf. md) | Extended data linked list |
Returns
boolean
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"}]));Inherited from
setxDataDouble
▸ setxDataDouble(appName, val): boolean
Set the double value in the specified XData type of the entity
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | number | double value |
Returns
boolean
Boolean value
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
}Inherited from
setxDataLong
▸ setxDataLong(appName, val): boolean
Set the long (integer) value in the specified XData type of the entity
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | number | long value |
Returns
boolean
Long value
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
}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
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | string | string value |
Returns
boolean
Is the setting successful
Inherited from
splitCurves
▸ splitCurves(pts): McDbObjectArray
Detach Curves
Parameters
| Name | Type | Description |
|---|---|---|
| Pts | McGePoint3d (2d. McGePoint3d. md) | breakpoint array |
Returns
Interrupted curve array.
Inherited from
splitCurvesFromParam
▸ splitCurvesFromParam(params): McDbObjectArray
Break the curve based on the curve parameters
Parameters
| Name | Type | Description |
|---|---|---|
| Params | number [] | curve parameter array |
Returns
Interrupted curve array.
Inherited from
McDbCurve.splitCurvesFromParam
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.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| _toCpp | boolean | true | Whether to synchronize data |
Returns
boolean
Inherited from
transformBy
▸ transformBy(transformationMatrix): boolean
Transform object
Parameters
| Name | Type | Description |
|---|---|---|
| TransformationMatrix | [McGeMatrix3d] (2d. McGeMatrix3d. md) | Transformation Matrix |
Returns
boolean
Inherited from
unErase
▸ unErase(): boolean
Anti delete object.
Returns
boolean
Inherited from
updateDisplay
▸ updateDisplay(): void
Display the updated display of the calling object
Returns
void
