Skip to content
On this page

Viewport Settings

In the process of drawing graphics in CAD, it is often encountered that the display of visual area is not suitable, then it is necessary to change the display range and Angle of visual area to adapt to the graphic display. In order to solve the above requirements, mxcad provides a series of methods in the example object McObject(), such as redrawing and updating view-area graphics, view-area customization, view-area rotation, etc., using these methods users can easily view and draw graphics.

Click McObject() to check the properties and methods in detail.

visual background color

We can directly set the background color of the viewport by calling the setViewBackgroundColor() method in the mxcad instance object.

ts
import { MxCpp } from "mxcad"

MxCpp.getCurrentMxCAD().setViewBackgroundColor(255, 255, 255);

Visual area graphics update, redraw

During the user drawing process, some useless anchor points will be generated at the end of each command. You can delete these anchor points by redrawing operations, so as to facilitate the viewing and drawing. We can update the viewport display by calling the updateDisplay() method in the mxcad instance object; Call updateLayerDisplayStatus() method to partially update the layer display; Call the regen() method to redo all objects on the plot.

ts
import { MxCpp } from "mxcad"

const mxcad = MxCpp.getCurrentMxCAD()
mxcad.regen()
mxcad.updateDisplay()
// mxcad.updateLayerDisplayStatus()

Visual area display range

  1. scale display range: We can call the mxcad instance object's zoomScale() method to scale the current display range, the parameter in this method is scale scale scale.
ts
import { MxCpp } from "mxcad"

MxCpp.getCurrentMxCAD().zoomScale(0.8)
  1. Custom display center: We can call the zoomCenter() method of the mxcad instance object to move the current display range to the specified position, the two parameters in the method dCenX, dCenY is the DWG drawing coordinates that are the center point of the view area display range.
ts
import { MxCpp } from "mxcad"

MxCpp.getCurrentMxCAD().zoomCenter(0,0)
  1. Customize the display range: We can call the mxcad instance object zoomW() method to move the current display range to the specified display range, the two parameters in the method minPt, maxPt are the minimum point and the maximum point of the display range.
ts
import { MxCpp, McGePoint3d } from "mxcad"

const mxcad = MxCpp.getCurrentMxCAD()
mxcad.zoomW(new McGePoint3d(0, 0), new McGePoint3d(30, 30))
  1. Show all: We can call the mxcad instance object's zoomAll() method to set the viewport scope to show the entire content of the drawing.
ts
import { MxCpp } from "mxcad"

MxCpp.getCurrentMxCAD().zoomAll()

Visual rotation

We can rotate the viewport by calling the mxcad instance object's zoomAngle() method to set the viewport Angle in PI.

ts
import { MxCpp, McGePoint3d } from "mxcad"

const mxcad = MxCpp.getCurrentMxCAD()
const lAng += Math.PI * 0.5;
mxcad.zoomAngle(lAng);

Visual translation

We can combine command lineMx_Pan command implementation viewport translation function.

ts
import { MxFun } from "mxdraw"

MxFun.sendStringToExecute("Mx_Pan");