Skip to content

[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McDbEllipse

Class: McDbEllipse ​

2d.McDbEllipse

Represents an elliptical arc entity. It includes methods for creating and modifying ellipsoidal arc properties.

Example

ts
   import { McDbEllipse, MxCpp } from "mxcad"
//Draw an elliptical arc
Const ellipse_arc=new McDbEllipse()//Construct an elliptical object
Ellipse_arc.center=new McGePoint3d (-380, -200)//Set object center point
Ellipse_arc.majorAxis=new McGeVector3d (0, 150, 0)//Set the object's principal axis vector
Ellipse_arc.minorAxis=new McGeVector3d (280, 0, 0)//Set the object's secondary axis vector
Ellipse_arc. startAngle=Math. PI/2//Set the starting angle of the object
Ellipse_rc.endAngle=Math. PI * 3/2//Set the end angle of the object
Ellipse_arc.trueColor=new McCMColor (0, 255, 255)//Set object color
MxCpp. getCurrentMxCAD(). drawEntity (ellipse_arc)//Draw an elliptical object

//Draw an ellipse
Const ellipse=new McDbEllipse()//Construct an elliptical object
Ellipse.center=new McGePoint3d (-200, -200)//Set the center of the object
Ellipse.majorAxis=new McGeVector3d (0, 300, 0)//Set the object's principal axis vector
Ellipse.radiusRatio=0.5//Set the ratio of the length of the secondary axis to the length of the main axis of the ellipse
Ellipse.trueColor=new McCMColor (255, 233, 0)//Set object color
MxCpp. getCurrentMxCAD(). rawEntity (ellipse)//Draw an elliptical object

Hierarchy ​

Table of contents ​

Constructors ​

Properties ​

Accessors ​

Methods ​

Constructors ​

constructor ​

• new McDbEllipse(cenx?, ceny?, cenz?, majorAxisx?, majorAxisy?, majorAxisz?, radiusRatio?, startAngle?, endAngle?)

Constructor.

Example

ts
import { McDbEllipse } from "mxcad";

const ellipse = new McDbEllipse();

Parameters ​

NameType
cenx?number | object
ceny?number
cenz?number
majorAxisx?number
majorAxisy?number
majorAxisz?number
radiusRatio?number
startAngle?number
endAngle?number

Overrides ​

McDbCurve.constructor

Properties ​

imp ​

• imp: any = 0

Internal implementation object.

Inherited from ​

McDbCurve.imp

Accessors ​

center ​

• get center(): McGePoint3d

Obtain the center coordinates.

Example

ts
import { McDbEllipse } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.setCenter(0,0,0);
const center = ellipse.center;

Returns ​

McGePoint3d

• set center(pt): void

Set the center coordinates.

Example

ts
import { McDbEllipse, McGePoint3d } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.center = new McGePoint3d(0,0,0);

Parameters ​

NameTypeDescription
PtMcGePoint3d (2d. McGePoint3d. md)Center coordinates

Returns ​

void


colorIndex ​

• get colorIndex(): number

Obtain object color index

Example

ts
 import { McDbEntity, ColorIndexType } from 'mxcad'
 const ent = new McDbEntity();
 ent.colorIndex = ColorIndexType.kByblock;
 console.log(ent.colorIndex)

Returns ​

number

Inherited from ​

McDbCurve.colorIndex

• set colorIndex(val): void

Set object color index

Parameters ​

NameTypeDescription
ValnumberColorIndexType

Returns ​

void

Inherited from ​

McDbCurve.colorIndex


drawOrder ​

• get drawOrder(): number

Display order of objects

Example

ts
//Assuming ent is a valid instance object
const order = ent.drawOrder();

Returns ​

number

Inherited from ​

McDbCurve.drawOrder

• set drawOrder(order): void

Display order of objects

Example

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

NameTypeDescription
Ordernumbersequential value

Returns ​

void

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


endAngle ​

• get endAngle(): number

Obtain the end angle of the elliptical arc

Example

ts
//Ellipse is a valid elliptical arc instance object
const endAngle = ellipse.endAngle;

Returns ​

number

• set endAngle(val): void

Set the end angle of the elliptical arc

Example

ts
import { McDbEllipse, McGeVector3d } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.endAngle = Math.PI/4;

Parameters ​

NameType
valnumber

Returns ​

void


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

Example

ts
 import { McDbEntity } from 'mxcad'
 const ent = new McDbEntity();
 ent.layer = "newLayerName";
 console.log(ent.layer)

Parameters ​

NameTypeDescription
ValstringLayer Name

Returns ​

void

Inherited from ​

McDbCurve.layer


layerId ​

• get layerId(): McObjectId

Get layer ID object

Example

ts
//Assuming ent is a valid instance object
const layerId = ent.layerId;

Returns ​

McObjectId

Inherited from ​

McDbCurve.layerId

• set layerId(id): void

Set Layer Id Object

Example

ts
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
Const layerId=mxcad. addLayer (Test Layer)
ent.layerId = layerId;

Parameters ​

NameType
idMcObjectId

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

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.linetype = "MyLineType";
console.log(ent.linetype)

Parameters ​

NameTypeDescription
ValstringLine type name

Returns ​

void

Inherited from ​

McDbCurve.linetype


linetypeId ​

• get linetypeId(): McObjectId

Get entity object line type ID

Example

ts
//Assuming ent is a valid instance object
const linetypeId = ent.linetypeId;

Returns ​

McObjectId

Inherited from ​

McDbCurve.linetypeId

• set linetypeId(id): void

Set entity object line type ID

Example

ts
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
const lineId = mxcad.addLinetypeEx("TestMyLine", '25,-5');
ent.linetypeId = lineId;

Parameters ​

NameType
idMcObjectId

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

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.linetypeScale = 0.8;
console.log(ent.linetypeScale)

Parameters ​

NameTypeDescription
ValnumberLine 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

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.lineweight = 20;
console.log(ent.lineweight)

Parameters ​

NameTypeDescription
Valnumberline weight

Returns ​

void

Inherited from ​

McDbCurve.lineweight


majorAxis ​

• get majorAxis(): McGeVector3d

Obtain the main axis vector

Example

ts
import { McDbEllipse } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.setMajorAxis(20,0,0);
const majorAxis = ellipse.majorAxis;

Returns ​

McGeVector3d

• set majorAxis(pt): void

Set the main axis vector.

Example

ts
import { McDbEllipse, McGeVector3d } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.majorAxis = new McGeVector3d(20,0,0)

Parameters ​

NameType
ptMcGeVector3d

Returns ​

void


minorAxis ​

• get minorAxis(): McGeVector3d

Obtain the secondary axis vector

Example

ts
import { McDbEllipse } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.setMajorAxis(20,0,0);
const minorAxis = ellipse.minorAxis;

Returns ​

McGeVector3d

• set minorAxis(pt): void

Set the secondary axis vector.

Example

ts
import { McDbEllipse, McGeVector3d } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.minorAxis = new McGeVector3d(20,0,0)

Parameters ​

NameType
ptMcGeVector3d

Returns ​

void


normal ​

• get normal(): McGeVector3d

Return the normal of the object

Example

ts

Returns ​

McGeVector3d

Inherited from ​

McDbCurve.normal

• set normal(val): void

Set the normal of the object

Example

ts

Parameters ​

NameType
valMcGeVector3d

Returns ​

void

Inherited from ​

McDbCurve.normal


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 ​

McDbCurve.objectName


radiusRatio ​

• get radiusRatio(): number

Obtain the ratio of the length of the secondary axis to the length of the main axis of an ellipse

Example

ts
//Ellipse is a valid elliptical arc instance object
const radiusRatio = ellipse.radiusRatio;

Returns ​

number

• set radiusRatio(val): void

Set the ratio of the length of the secondary axis to the length of the main axis of the ellipse

Example

ts
import { McDbEllipse, McGeVector3d } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.radiusRatio = 4;

Parameters ​

NameType
valnumber

Returns ​

void


startAngle ​

• get startAngle(): number

Obtain the starting angle of the elliptical arc

Example

ts
//Ellipse is a valid elliptical arc instance object
const startAngle = ellipse.startAngle;

Returns ​

number

• set startAngle(val): void

Set the starting angle of the elliptical arc

Example

ts
import { McDbEllipse, McGeVector3d } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.startAngle = Math.PI/4;

Parameters ​

NameType
valnumber

Returns ​

void


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

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.textStyle = "st_style";

Parameters ​

NameTypeDescription
ValstringText style name

Returns ​

void

Inherited from ​

McDbCurve.textStyle


textStyleId ​

• get textStyleId(): McObjectId

Get entity text style

Example

ts
//Assuming ent is a valid instance object
const textStyleId = ent.textStyleId;

Returns ​

McObjectId

Inherited from ​

McDbCurve.textStyleId

• set textStyleId(id): void

Set the text style of the entity

Example

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

NameType
idMcObjectId

Returns ​

void

Inherited from ​

McDbCurve.textStyleId


trueColor ​

• get trueColor(): McCmColor

Obtain the color of the object

Example

ts
 import { McDbEntity, McCmColor} from 'mxcad'
 const ent = new McDbEntity();
 ent.trueColor = new McCmColor(255, 0, 0);
 console.log(ent.trueColor)

Returns ​

McCmColor

Inherited from ​

McDbCurve.trueColor

• set trueColor(val): void

Set object color

Parameters ​

NameType
valMcCmColor

Returns ​

void

Inherited from ​

McDbCurve.trueColor


visible ​

• get visible(): boolean

Is the object visible

Returns ​

boolean

Inherited from ​

McDbCurve.visible

• set visible(val): void

Set whether it is visible

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.visible = true;
console.log(ent.visible)

Parameters ​

NameTypeDescription
ValbooleanBoolean value

Returns ​

void

Inherited from ​

McDbCurve.visible

Methods ​

IntersectWith ​

▸ IntersectWith(intersectObject, exOption): McGePoint3dArray

Intersection with other entities to obtain the intersection point

Example

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

NameTypeDescription
IntersectObject[McDbEntity] (2d. McDbEntity. md)The entity object that needs to intersect is the entity object
ExOptionIntersection (../enums/2d. McDb. Intersect. md)Intersection options

Returns ​

McGePoint3dArray

Obtain all intersection points

Inherited from ​

McDbCurve.IntersectWith


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

ts
//Assuming obj is a database object
obj.assertObjectModification()

Parameters ​

NameTypeDefault value
autoUndobooleanfalse

Returns ​

number

Inherited from ​

McDbCurve.assertObjectModification


clone ​

▸ clone(): null | McDbObject

Clone objects.

Example

ts
//Assuming obj is a database object
const obj_clone = obj.clone();

Returns ​

null | McDbObject

The cloned object.

Inherited from ​

McDbCurve.clone


createExtensionDictionary ​

▸ createExtensionDictionary(): boolean

Create extended dictionary data for objects

Example

ts
//Assuming obj is a database object
const res = obj.createExtensionDictionary();

Returns ​

boolean

Inherited from ​

McDbCurve.createExtensionDictionary


deleteXData ​

▸ deleteXData(appName): boolean

Delete data related to entity specified application name

Example

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

NameTypeDescription
AppNamestringExtended Data Name

Returns ​

boolean

Inherited from ​

McDbCurve.deleteXData


disableDisplay ​

▸ disableDisplay(isDisable): void

Disable automatic update display of objects

Example

ts
import { McDbLine } from 'mxcad'
const line1 = new McDbLine(new McGePoint3d(0,0,0), new McGePoint3d(20,1,0));
line1.disableDisplay(true)

Parameters ​

NameTypeDescription
IsDisablebooleanDo you want to disable automatic object update display

Returns ​

void

Inherited from ​

McDbCurve.disableDisplay


erase ​

▸ erase(): boolean

Delete object.

Example

ts
//Assuming obj is a database object
const res = obj.erase();
console.log(res);

Returns ​

boolean

Whether the deletion was successful.

Inherited from ​

McDbCurve.erase


explode ​

▸ explode(): MxCADResbuf

Break the object and return the linked list of the object's data after being broken

Example

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

MxCADResbuf

Rebuf data

Inherited from ​

McDbCurve.explode


getAllAppName ​

▸ getAllAppName(): McGeStringArray

Get the application name (AppName) of all XData records contained in the entity

Example

ts
//Assuming ent is a valid instance object
const appNames = ent.getAllAppName();
console.log(appNames);

Returns ​

McGeStringArray

Inherited from ​

McDbCurve.getAllAppName


getArea ​

▸ getArea(): Object

Calculate Area

Example

ts
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

NameType
retboolean
valnumber

Inherited from ​

McDbCurve.getArea


getBoundingBox ​

▸ getBoundingBox(): Object

Obtain the minimum outsourcing of the object

Example

ts
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

NameType
maxPtMcGePoint3d
minPtMcGePoint3d
retboolean

Inherited from ​

McDbCurve.getBoundingBox


getClosestPointTo ​

▸ getClosestPointTo(givenPnt, isExtend): Object

Obtain the closest point from a point to the curve

Example

ts
import { McGePoint3d, McDbCircle, MxCADUiPrPoint, MxCpp } from "mxcad"

const center = new McGePoint3d(0,0,0);
const circle = new McDbCircle(center, 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();

Parameters ​

NameTypeDescription
GivenPnt[McGePoint3d] (2d. McGePoint3d. md)Reference Point
IsExtendbooleanWhether to extend entity

Returns ​

Object

Point objects and execution results.

NameType
retboolean
valMcGePoint3d

Inherited from ​

McDbCurve.getClosestPointTo


getDatabase ​

▸ getDatabase(): McDbDatabase

Get the database where the object is located

Example

ts
//Assuming obj is a database object
const data = obj.getDatabase();

Returns ​

McDbDatabase

Return to database

Inherited from ​

McDbCurve.getDatabase


getDatabaseIndexId ​

▸ getDatabaseIndexId(): number

Get the index ID of the object

Example

ts
//Assuming obj is a database object
const id = obj.getDatabaseIndexId();

Returns ​

number

Inherited from ​

McDbCurve.getDatabaseIndexId


getDistAtParam ​

▸ getDistAtParam(param): Object

Get the distance at the parameter location.

Example

ts
//Assuming curve is an effective curve instance object
const res = curve.getDistAtParam(2);
if(res.ret){
  console.log(res.val)
}

Parameters ​

NameTypeDescription
Parameter position:

Returns ​

Object

Distance and execution results.

NameType
retboolean
valnumber

Inherited from ​

McDbCurve.getDistAtParam


getDistAtPoint ​

▸ getDistAtPoint(pt): Object

Obtain the distance and position of points on the curve.

Example

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

Parameters ​

NameTypeDescription
Pt[McGePoint3d] (2d. McGePoint3d. md)Distance position

Returns ​

Object

Points and execution results.

NameType
retboolean
valnumber

Inherited from ​

McDbCurve.getDistAtPoint


getEndParam ​

▸ getEndParam(): Object

Get the end parameter.

Example

ts
//Assuming curve is an effective curve instance object
const endPa = curve.getEndParam();
if(endPa.ret){
  console.log(endPa.val)
}

Returns ​

Object

End parameters and execution results.

NameType
retboolean
valnumber

Inherited from ​

McDbCurve.getEndParam


getEndPoint ​

▸ getEndPoint(): Object

Obtain the endpoint of the curve

Example

ts
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)
}

Returns ​

Object

The endpoint and execution result of the curve.

NameType
retboolean
valMcGePoint3d

Inherited from ​

McDbCurve.getEndPoint


getExtensionDictionary ​

▸ getExtensionDictionary(): McDbDictionary

Obtain the extended dictionary data of the object

Example

ts
//Assuming obj is a database object
const id = obj.getOwnerID();

Returns ​

McDbDictionary

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

Example

ts
import { McGePoint3d, McDbCircle } from "mxcad"

const center = new McGePoint3d(0,0,0);
const circle = new McDbCircle(center, 20);
const vec = circle.getFirstDeriv(new McGePoint3d(20,0,0));// Target point tangent vector
if(vec.ret){
 const val = vec.val;
}

Parameters ​

NameTypeDescription
Pt[McGePoint3d] (2d. McGePoint3d. md)Points on the curve

Returns ​

Object

The first derivative of the curve and its execution result.

NameType
retboolean
valMcGeVector3d

Inherited from ​

McDbCurve.getFirstDeriv


getFirstDerivFromParam ​

▸ getFirstDerivFromParam(param): Object

Obtain the first derivative of the curve through curve parameters

Example

ts
//Assuming curve is an effective curve instance object
const res = curve.getFirstDerivFromParam(5);
if(res.ret){
  console.log(res.val)
}

Parameters ​

NameTypeDescription
Paramnumbercurve parameters

Returns ​

Object

The first derivative of the curve and its execution result.

NameType
retboolean
valMcGeVector3d

Inherited from ​

McDbCurve.getFirstDerivFromParam


getGripPoints ​

▸ getGripPoints(): McGePoint3dArray

Get the control points of the object

Example

ts
//Assuming obj is a database object
const ptArr = obj.getGripPoints();

Returns ​

McGePoint3dArray

Inherited from ​

McDbCurve.getGripPoints


getHandle ​

▸ getHandle(): string

Obtain object handle

Example

ts
//Assuming obj is a database object
const handle = obj.getHandle();

Returns ​

string

Return object handle

Inherited from ​

McDbCurve.getHandle


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 ​

McDbCurve.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 ​

McDbCurve.getJson


getLength ​

▸ getLength(): Object

Obtain the length of the curve

Example

ts
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)
   });

Returns ​

Object

NameType
retboolean
valnumber

Inherited from ​

McDbCurve.getLength


getObjectID ​

▸ getObjectID(): McObjectId

Get the object ID.

Example

ts
import { McDbObject } from "mxcad";
const id = obj.getObjectID();

Returns ​

McObjectId

Object ID.

Inherited from ​

McDbCurve.getObjectID


getOwnerID ​

▸ getOwnerID(): number

Obtain the ID of the object owner

Example

ts
//Assuming obj is a database object
const id = obj.getOwnerID();

Returns ​

number

Inherited from ​

McDbCurve.getOwnerID


getParamAtDist ​

▸ getParamAtDist(dist): Object

Obtain parameters at the distance position.

Example

ts
//Assuming curve is an effective curve instance object
const res = curve.getParamAtDist(0);
if(res.ret){
  console.log(res.val)
}

Parameters ​

NameTypeDescription
DistNumberDistance Position

Returns ​

Object

Parameters and execution results.

NameType
retboolean
valnumber

Inherited from ​

McDbCurve.getParamAtDist


getParamAtPoint ​

▸ getParamAtPoint(pt): Object

Obtain the curve parameters at a certain point on the curve

Example

ts
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.getParamAtPoint(pt1);
if(res.ret){
  const val = res.val;
  console.log(val);
}

Parameters ​

NameTypeDescription
Pt[McGePoint3d] (2d. McGePoint3d. md)Points on the curve

Returns ​

Object

Curve parameters and execution results.

NameType
retboolean
valnumber

Inherited from ​

McDbCurve.getParamAtPoint


getPointAtDist ​

▸ getPointAtDist(dist): Object

Obtain the point at the distance position.

Example

ts
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)
}

Parameters ​

NameTypeDescription
DistNumberDistance Position

Returns ​

Object

Points and execution results.

NameType
retboolean
valMcGePoint3d

Inherited from ​

McDbCurve.getPointAtDist


getPointAtParam ​

▸ getPointAtParam(param): Object

Obtain the coordinates of the point where the curve parameters are located

Example

ts
//Assuming curve is an effective curve instance object
const res = curve.getPointAtParam(5);
if(res.ret){
  console.log(res.val)
}

Parameters ​

NameTypeDescription
Paramnumbercurve parameters

Returns ​

Object

Point objects and execution results.

NameType
retboolean
valMcGePoint3d

Inherited from ​

McDbCurve.getPointAtParam


getSamplePoints ​

▸ getSamplePoints(dApproxEps?): MxCADResbuf

Discretize the curve into a pile of points

Example

ts
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 resBuf = line.getSamplePoints(0.1);

Parameters ​

NameTypeDefault valueDescription
DApproxEpsnumber0.0001sampling interval

Returns ​

MxCADResbuf

Rebuf data

Inherited from ​

McDbCurve.getSamplePoints


getStartParam ​

▸ getStartParam(): Object

Get the starting parameters.

Example

ts
//Assuming curve is an effective curve instance object
const startPa = curve.getStartParam();
if(startPa.ret){
  console.log(startPa.val)
}

Returns ​

Object

Initial parameters and execution results.

NameType
retboolean
valnumber

Inherited from ​

McDbCurve.getStartParam


getStartPoint ​

▸ getStartPoint(): Object

Obtain the starting point of the curve

Example

ts
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)
}

Returns ​

Object

The starting point and execution result of the curve.

NameType
retboolean
valMcGePoint3d

Inherited from ​

McDbCurve.getStartPoint


getxData ​

▸ getxData(appName?): MxCADResbuf

Obtain the extended data of the object

Example

ts
//Assuming ent is a valid instance object
const xData = ent.getXData();

Parameters ​

NameTypeDefault valueDescription
AppNamestring""Extended Data Name

Returns ​

MxCADResbuf

Inherited from ​

McDbCurve.getxData


getxDataDouble ​

▸ getxDataDouble(appName): Object

Retrieve the double value from the specified XData type of the entity

Example

ts
//Assuming ent is a valid instance object
let data = ent.getxDataDouble("DataName");
if(data.ret){
  console.log(data.val)
}

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name

Returns ​

Object

Double value

NameType
retboolean
valnumber

Inherited from ​

McDbCurve.getxDataDouble


getxDataLong ​

▸ getxDataLong(appName): Object

Retrieve the long (integer) value from the specified XData type of the entity

Example

ts
//Assuming ent is a valid instance object
let data = ent.getxDataLong("DataName");
if(data.ret){
  console.log(data.val)
}

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name

Returns ​

Object

Long value

NameType
retboolean
valnumber

Inherited from ​

McDbCurve.getxDataLong


getxDataPoint ​

▸ getxDataPoint(appName): Object

Retrieve point objects from the specified XData type of entity

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name

Returns ​

Object

Obtain results and 3D point objects

NameType
retboolean
valMcGePoint3d

Inherited from ​

McDbCurve.getxDataPoint


getxDataString ​

▸ getxDataString(appName): Object

Retrieve XData information associated with a specific entity and return it in string form

Example

ts
//Assuming ent is a valid instance object
let data = ent.getxDataString("DataName");
if(data.ret){
  console.log(data.val)
}

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name

Returns ​

Object

Val XData information | whether ret returns success

NameType
retboolean
valstring

Inherited from ​

McDbCurve.getxDataString


highlight ​

▸ highlight(isHighlight): void

Set whether the object is highlighted

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.highlight(true);

Parameters ​

NameTypeDescription
IsHighlightbooleanIs it highlighted

Returns ​

void

Inherited from ​

McDbCurve.highlight


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 ​

McDbCurve.initTempObject


isErased ​

▸ isErased(): boolean

Has the object been deleted

Example

ts
//Assuming obj is a database object
const res = obj.isErased();
console.log(res);

Returns ​

boolean

Inherited from ​

McDbCurve.isErased


isHaveExtensionDictionary ​

▸ isHaveExtensionDictionary(): boolean

Is there any extended dictionary data available

Example

ts
//Assuming obj is a database object
const res = obj.isHaveExtensionDictionary();

Returns ​

boolean

Inherited from ​

McDbCurve.isHaveExtensionDictionary


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 ​

McDbCurve.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 ​

McDbCurve.isNull


mirror ​

▸ mirror(point1, point2): boolean

Mirror oriented object

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.mirror(new McGePoint3d(0,0,0), new McGePoint3d(20,10,0))

Parameters ​

NameTypeDescription
Point1[McGePoint3d] (2d. McGePoint3d. md)Mirror Base Point
point2McGePoint3d-

Returns ​

boolean

Inherited from ​

McDbCurve.mirror


move ​

▸ move(fromPoint, toPoint): boolean

move objects

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.move(new McGePoint3d(0,0,0), new McGePoint3d(20,0,0))

Parameters ​

NameTypeDescription
From Point[McGePoint3d] (2d. McGePoint3d. md)Move the starting point
ToPoint[McGePoint3d] (2d. McGePoint3d. md)Move End Point

Returns ​

boolean

Inherited from ​

McDbCurve.move


moveGripPointsAt ​

▸ moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset): any

Control points for moving objects

Example

ts
//Assuming obj is a database object
obj.moveGripPointsAt(1,10,10,10);

Parameters ​

NameTypeDescription
IIndexNumberIndex
DXOffsetnumberX-axis offset
DYOffsetnumberY-axis offset
DZOffsetnumberZ-axis offset

Returns ​

any

Inherited from ​

McDbCurve.moveGripPointsAt


offsetCurves ​

▸ offsetCurves(dOffsetDist, ptOffsetRef): McDbObjectArray

Obtain offset curve

Example

ts
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);
   });

Parameters ​

NameTypeDescription
DOffsetDistnumberoffset distance
PtOffsetRef[McGePoint3d] (2d. McGePoint3d. md)Offset point

Returns ​

McDbObjectArray

Offset object array.

Inherited from ​

McDbCurve.offsetCurves


rotate ​

▸ rotate(basePoint, dRotationAngle): boolean

Rotate object

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.rotate(new McGePoint3d(0,0,0), Math.PI)

Parameters ​

NameTypeDescription
BasePoint[McGePoint3d] (2d. McGePoint3d. md)Rotate the base point
DRotationAnglenumberRotation angle

Returns ​

boolean

Inherited from ​

McDbCurve.rotate


scaleEntity ​

▸ scaleEntity(basePoint, dScaleFactor): boolean

Scaling objects

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.scaleEntity(new McGePoint3d(0,0,0), 0.5)

Parameters ​

NameTypeDescription
BasePoint[McGePoint3d] (2d. McGePoint3d. md)Scale Base Point
DScaleFactornumberscaling factor (<1 zoom out;>1 zoom in)

Returns ​

boolean

Inherited from ​

McDbCurve.scaleEntity


setCenter ​

▸ setCenter(x, y, z?): void

Set the center coordinates.

Example

ts
import { McDbEllipse } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.setCenter(0,0,0);

Parameters ​

NameTypeDescription
XnumberThe x-coordinate of the center of the circle
YnumberThe y-coordinate of the center of the circle
z?NumberCenter z-coordinate

Returns ​

void


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 ​

McDbCurve.setJson


setMajorAxis ​

▸ setMajorAxis(x, y, z?): void

Set the main axis vector

Example

ts
import { McDbEllipse } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.setMajorAxis(20,0,0);

Parameters ​

NameTypeDescription
Xnumberx coordinate
Ynumbery coordinate
z?Numberz coordinate

Returns ​

void


setMinorAxis ​

▸ setMinorAxis(x, y, z?): void

Set the secondary axis vector

Example

ts
import { McDbEllipse } from "mxcad";

const ellipse = new McDbEllipse();
ellipse.setMinorAxis(20,0,0);

Parameters ​

NameTypeDescription
Xnumberx coordinate
Ynumbery coordinate
z?Numberz coordinate

Returns ​

void


setxData ​

▸ setxData(xdata): boolean

Set extended data for objects

Example

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

NameTypeDescription
Xdata[MxCADResbuf] (2d. MxCADResbuf. md)Extended data linked list

Returns ​

boolean

Inherited from ​

McDbCurve.setxData


setxDataDouble ​

▸ setxDataDouble(appName, val): boolean

Set the double value in the specified XData type of the entity

Example

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

NameTypeDescription
AppNamestringExtended Data Name
Valnumberdouble value

Returns ​

boolean

Boolean value

Inherited from ​

McDbCurve.setxDataDouble


setxDataLong ​

▸ setxDataLong(appName, val): boolean

Set the long (integer) value in the specified XData type of the entity

Example

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

NameTypeDescription
AppNamestringExtended Data Name
Valnumberlong value

Returns ​

boolean

Long value

Inherited from ​

McDbCurve.setxDataLong


setxDataPoint ​

▸ setxDataPoint(appName, val): boolean

Set the point object in the specified XData type of the entity

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name
Val[McGePoint3d] (2d. McGePoint3d. md)Point Object

Returns ​

boolean

Obtain results and 3D point objects

Inherited from ​

McDbCurve.setxDataPoint


setxDataString ​

▸ setxDataString(appName, val): boolean

Set XData information associated with a specific entity and set it in string form

Example

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

NameTypeDescription
AppNamestringExtended Data Name
Valstringstring value

Returns ​

boolean

Is the setting successful

Inherited from ​

McDbCurve.setxDataString


splitCurves ​

▸ splitCurves(pts): McDbObjectArray

Detach Curves

Example

ts
import { MxCpp } from "mxcad"
//PointsArr: breakpoint array event: McDbCurve
   event.splitCurves(PointsArr).forEach((e:McDbCurve, index:number) => {
       if(index % 2 === 0){
           MxCpp.getCurrentCAD().drawEntity(e as McDbEntity)
       }
   })

Parameters ​

NameTypeDescription
PtsMcGePoint3d (2d. McGePoint3d. md)breakpoint array

Returns ​

McDbObjectArray

Interrupted curve array.

Inherited from ​

McDbCurve.splitCurves


splitCurvesFromParam ​

▸ splitCurvesFromParam(params): McDbObjectArray

Break the curve based on the curve parameters

Parameters ​

NameTypeDescription
Paramsnumber []curve parameter array

Returns ​

McDbObjectArray

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.

Example

ts
//Assuming ent is a valid instance object
const res = ent.syncData(true);
if(res){
//Synchronization successful
}else{
//Synchronization failed
}

Parameters ​

NameTypeDefault valueDescription
_toCppbooleantrueWhether to synchronize data

Returns ​

boolean

Inherited from ​

McDbCurve.syncData


transformBy ​

▸ transformBy(transformationMatrix): boolean

Transform object

Example

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

NameTypeDescription
TransformationMatrix[McGeMatrix3d] (2d. McGeMatrix3d. md)Transformation Matrix

Returns ​

boolean

Inherited from ​

McDbCurve.transformBy


unErase ​

▸ unErase(): boolean

Anti delete object.

Example

ts
//Assuming obj is a database object
const res = obj.unErase();
console.log(res);

Returns ​

boolean

Inherited from ​

McDbCurve.unErase


updateDisplay ​

▸ updateDisplay(): void

Display the updated display of the calling object

Example

ts
//Assuming ent is a valid instance object
ent.updateDisplay()

Returns ​

void

Inherited from ​

McDbCurve.updateDisplay