measure

4/28/2022

# Aligned Dimension Measurement MxDbAlignedDimension Object

We can use Mx.MxDbAlignedDimension() to display and draw aligned dimension graphics.

Click on Mx.MxDbAlignedDimension API (opens new window) for details on the properties and method descriptions.


import Mx from "mxdraw"

const getPoint = new Mx.MrxDbgUiPrPoint();

// First click
getPoint.go(async (status) => {
    if (status !== Mx.MrxDbgUiPrBaseReturn.kOk) {
        return;
    }

    // Current mouse position
    const pt1 = getPoint.value();
   
    // Instantiate the alignment annotation
    let alignedDimension = new Mx.MxDbAlignedDimension();
    // Set the position of the first point
    alignedDimension.setPoint1(pt1);

    // Set up the dynamic drawing callback function
    getPoint.setUserDraw((currentPoint, worldDrawComment) => {
        // Set the position of the second point
        alignedDimension.setPoint2(currentPoint);
        // Draw
        worldDrawComment.drawCustomEntity(alignedDimension);
    });

    // Second click
     alignedDimension.setPoint2(await getPoint.go());
    Mx.MxFun.getCurrentDraw().addMxEntity(alignedDimension);

});

Note:

Result: The alignment annotation is similar to drawing a line.

# Lead Line Coordinate Annotation MxDbCoord

Use this to annotate the coordinate position of a point. Click on Mx.MxDbCoord API (opens new window) for details on the properties and method descriptions.


import Mx from "mxdraw"

// Instantiate the get-point object
const getPoint = new Mx.MrxDbgUiPrPoint();

getPoint.go(async (status) => {
    if (status !== Mx.MrxDbgUiPrBaseReturn.kOk) {
      return;
    }
    let coord = new Mx.MxDbCoord();
    coord.point1 = getPoint.value();

    // Set up the dynamic drawing callback function
    getPoint.setUserDraw((currentPoint, worldDrawComment) => {
      coord.point2 = currentPoint;
      // Draw the line segment object
      worldDrawComment.drawCustomEntity(coord);
    });

    // Second click
     coord.point2 = await getPoint.go();
    Mx.MxFun.getCurrentDraw().addMxEntity(coord);
  })

Note:

# Lead Text Annotation MxDbLeadComment

Click on Mx.MxDbLeadComment API (opens new window) for details on the properties and method descriptions.

  const getPoint = new Mx.MrxDbgUiPrPoint();

  getPoint.go(async (status) => {
      if (status !== Mx.MrxDbgUiPrBaseReturn.kOk) {
          return;
      }
      let leadComment = new Mx.MxDbLeadComment();
      // Set the flag point
      leadComment.point1 = getPoint.value();
      leadComment.text = "Text Annotation";
      leadComment.textHeight =Mx.MxFun.screenCoordLong2Doc(20);

      getPoint.setUserDraw((currentPoint, worldDrawComment) => {
          // The position of the annotation text
          leadComment.point2 = currentPoint;
          worldDrawComment.drawCustomEntity(leadComment);
      });

      
    leadComment.point2 = await getPoint.go();
    Mx.MxFun.getCurrentDraw().addMxEntity(leadComment);
  })

Note:

# Cloud-Boxed Lead Review Annotation MxDbRectBoxLeadComment

Click on Mx.MxDbRectBoxLeadComment API (opens new window) for details on the properties and method descriptions.

const getPoint = new Mx.MrxDbgUiPrPoint();

getPoint.go(async (status) => {
    if (status !== Mx.MrxDbgUiPrBaseReturn.kOk) {
        return;
    }
    let rectBoxLeadComment = new Mx.MxDbRectBoxLeadComment();
    rectBoxLeadComment.point1 = getPoint.value();
    // Set the radius of the cloud-boxed arc for review
    rectBoxLeadComment.radius = Mx.MxFun.screenCoordLong2Doc(10);
    // Text annotation
    rectBoxLeadComment.text = "12333";
    rectBoxLeadComment.textHeight =Mx.MxFun.screenCoordLong2Doc(20);

    getPoint.setUserDraw((currentPoint, worldDrawComment) => {
        rectBoxLeadComment.point2 = currentPoint;
        worldDrawComment.drawCustomEntity(rectBoxLeadComment);
    });

    // Second click
    rectBoxLeadComment.point2 = await getPoint.go();
    getPoint.setUserDraw((currentPoint, worldDrawComment) => {
       rectBoxLeadComment.point3 = currentPoint;
       worldDrawComment.drawCustomEntity(rectBoxLeadComment);
    });
    
    // The position of the text
    rectBoxLeadComment.point3 = await getPoint.go();
    Mx.MxFun.getCurrentDraw().addMxEntity(rectBoxLeadComment);
})

Note:

# Angle Measurement

Click on Mx.MxDb2LineAngularDimension API (opens new window) for details on the properties and method descriptions.

const getPoint = new Mx.MrxDbgUiPrPoint();
// Mouse click
getPoint.go(async (status) => {
    if (status !== Mx.MrxDbgUiPrBaseReturn.kOk) {
        return;
    }
    let ang = new Mx.MxDb2LineAngularDimension();
    
    // The starting point of the angle measurement
    ang.point1 = getPoint.value();

    getPoint.setUserDraw((currentPoint, worldDrawComment) => {
        // The specific position of the angle measurement
        ang.point2 = currentPoint;
        // Dynamically draw a line segment
        worldDrawComment.drawLine(ang.point1, currentPoint);
    });

     // Second click
    ang.point2 = await getPoint.go();
    getPoint.setUserDraw((currentPoint, worldDrawComment) => {
        // The end point of the angle measurement
        ang.point3 = currentPoint;
       worldDrawComment.drawCustomEntity(ang);
    });
    ang.point3 = await getPoint.go();
    Mx.MxFun.getCurrentDraw().addMxEntity(ang);

});


Note: