CadViewports
from OpenCAD2D import CadViewports
class CadViewports(System.Object) ยท CadViewports in the .NET reference
The arithmetic of model space seen through a viewport of a layout: the view of the canvas in model units, the view a viewport takes from it back, a box of model space fitted to the frame, and the scales a viewport is set to.
Properties and fields
StandardScales
StandardScales: ClassVar[System.Collections.Generic.IReadOnlyList[str]]
Gets the standard scales a viewport is set to, as the status bar and the Properties' Standard scale offer them: 1:1, 1:2, 1:4, 1:5, 1:8, 1:10, 1:16, 1:20, 1:30, 1:40, 1:50, 1:100, 2:1, 4:1, 8:1, 10:1 and 100:1.
Methods
CanWorkThrough
@staticmethod
def CanWorkThrough(viewport: DxfViewport) -> bool
Gets whether a viewport's model space can be worked in through it: on and not the sheet's own, with a frame and a view of some size, its view a plan seen from above (the canvas shows model space through it at one scale). A plan twisted (group 51) is one: the canvas shows it turned, the cursor, the crosshair and the UCS icon with it.
Fit
@staticmethod
def Fit(viewport: DxfViewport, box: DisplayBox) -> tuple[GeoPoint2, float]
The view that shows a box of model space wholly in a viewport's frame, as ZOOM Window or Extents in a viewport: about the box's middle, as high as the box or as its width needs in the frame's proportion; through a twisted view, the box as the view turns it.
FromView
@staticmethod
def FromView(viewport: DxfViewport, view: GeoPoint2) -> GeoPoint2
The point of model space a point in the coordinates of a viewport's view stands for: the way back from CadViewports.ToView.
HasPlanView
@staticmethod
def HasPlanView(viewport: DxfViewport) -> bool
Gets whether a viewport looks straight down on model space, its view direction (group 16) the world's Z: the only view the canvas can work through, and the one the display draws as a plan, without a projection. A viewport set up in AutoCAD with a south-east isometric view, direction (1, -1, 1), has none; nor has one that looks from below.
ModelView
@staticmethod
def ModelView(paper: CadView, viewport: DxfViewport) -> CadView
The view of the canvas in model units through a viewport: the paper view scaled by the viewport's scale, about the point of model space under the middle of the canvas. A viewport at 1:20 seen at 2 pixels to the paper unit is seen at a tenth of a pixel to the model unit.
ScaleName
@staticmethod
def ScaleName(scale: float) -> str
The name of a viewport's scale, the paper's units to the model's: a standard one as the list writes it, 1:50; another to the third place, 1:37.5 or 3.125:1.
ToModel
@staticmethod
def ToModel(viewport: DxfViewport, paper: GeoPoint2) -> GeoPoint2
The point of model space a point of the paper shows through a viewport.
ToPaper
@staticmethod
def ToPaper(viewport: DxfViewport, model: GeoPoint2) -> GeoPoint2
The point of the paper a point of model space is shown at through a viewport.
ToView
@staticmethod
def ToView(viewport: DxfViewport, model: GeoPoint2) -> GeoPoint2
A point of model space in the coordinates of a viewport's view, as AutoCAD's display coordinates (TRANS 0 to 2): about the view's target and turned by its twist. Through a viewport twisted 30 degrees about the origin, (100, 0) is (86.603, 50).
@staticmethod
def ToView(viewport: DxfViewport, model: GeoPoint3) -> GeoPoint2
A point of model space, height and all, in the coordinates of a viewport's view, as AutoCAD's display coordinates (TRANS 0 to 2): the point taken from the view's target, along the view's axes, then turned by its twist. Through a viewport looking from (1, -1, 1), the point (100, 0, 0) is (70.711, -40.825), (0, 0, 100) is (0, 81.650), and the depth, which is its third coordinate, is dropped. Through a plan it is the point of CadViewports.ToView whatever its height.
TryReadScale
@staticmethod
def TryReadScale(name: str) -> tuple[bool, float]
The paper length of one model unit a scale's name gives, 0.02 for 1:50; false for a name that is none.
ViewBox
@staticmethod
def ViewBox(viewport: DxfViewport) -> DisplayBox
The box of model space a viewport's frame shows: through a twisted view, the box about the frame turned.
ViewOf
@staticmethod
def ViewOf(paper: CadView, model: CadView, viewport: DxfViewport) -> tuple[GeoPoint2, float]
The view a viewport takes from a view of the canvas in model units, the paper's staying as it is: the scale the two zooms give and the model point at the middle of the frame. The way back from CadViewports.ModelView, so a model view zoomed about the cursor gives the viewport's view zoomed there.