Ray
We can create a ray by instantiating an McDbRay() object. A ray is a straight line that starts from a base point and extends infinitely along a specified direction, commonly used for auxiliary positioning, measurement and constructing geometric relationships. Draw a ray by setting the basePoint and unitDir of the McDbRay() instance object, or you can directly call the setBasePoint(x, y, z) and setUnitDir(x, y, z) methods to set the base point and direction vector respectively, and can also set a variety of properties such as ray color trueColor, layer layer, linear scale linetypeScale, etc.
McDbRay inherits from McDbCurve, so it can also call curve methods such as getPointAtDist() to get the point at a specified distance on the curve, and getFirstDeriv() to get the first derivative, just like a curve.
Click McDbRay() for detailed property and method descriptions.
import { MxCpp, McCmColor, McDbRay, McGePoint3d, McGeVector3d } from "mxcad"
const mxcad = MxCpp.getCurrentMxCAD()
// Set the base point and direction vector through properties
const ray = new McDbRay()
ray.basePoint = new McGePoint3d(0, 0, 0)
ray.unitDir = new McGeVector3d(1, 0, 0)
ray.trueColor = new McCmColor(255, 0, 0)
mxcad.drawEntity(ray)
// Set the base point and direction vector through methods
const ray_1 = new McDbRay()
ray_1.setBasePoint(100, 100, 0)
ray_1.setUnitDir(1, 1, 0)
ray_1.trueColor = new McCmColor(0, 255, 0)
mxcad.drawEntity(ray_1)