Class DxfViewport
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
A VIEWPORT of a DXF file, as AutoCAD's Viewport: a window of a layout's sheet onto model space, its place and size
on the sheet, the view it shows, its snap and grid, its user coordinate system and the layers frozen in it.
public sealed class DxfViewport : DxfEntity
- Inheritance
-
DxfViewport
- Inherited Members
Remarks
A viewport 200 wide and 150 high about (150, 100) on the sheet that shows model space about (5 000, 3 000) at 1:50 has CenterPoint (150, 100, 0), Width 200, Height 150, ViewCenter (5 000, 3 000) and ViewHeight 7 500: CustomScale is 150 / 7 500, 0.02, and StandardScale Scale1To50. Its Number is the id the file gives it (group 69) while it is on, 1 for the viewport that shows the sheet itself, and -1 turned off.
A file of R2000 or later holds the view in the viewport's own groups (12 to 51, 90 for its flags, 331 for its frozen
layers); one of R12, R13 or R14 in its extended data of ACAD, after MVIEW, each value in its place, read and
written there. What those have not, as the user coordinate system or the plot style, reads as AutoCAD's default and is
not set there.
The view is not drawn anew: a change to it is written, and AutoCAD shows it when the drawing is next opened.
TransformBy(GeoTransform3) moves and scales the viewport on its sheet, as AutoCAD's TransformBy does, the
view in it kept: a viewport scaled by 2 shows the same part of model space twice as large. (AutoCAD's SCALE command
does otherwise, keeping the scale of the view; the presenter's SCALE follows the command.)
Constructors
- DxfViewport()
Initializes a viewport made in code, as AutoCAD's
new Viewport(): about the origin, 1 by 1, off, showing the top view of model space about its origin; give it its place, size and view, append it to a layout of paper space and turn it On.
Properties
- AmbientLightColor
Gets or sets the colour of the ambient light (groups 63, 421 and 431, from R2007), as AutoCAD's
AmbientLightColor: its true colour where it has one, else its colour of the index; the index 250, a dark grey, where the record gives none.
- BackClipDistance
Gets or sets how far the back clipping plane is from the target (group 44), as AutoCAD's
BackClipDistance.
- BackClipOn
Gets or sets whether the view is clipped behind (flag 4), as AutoCAD's
BackClipOn.
- Background
Gets the background of the view (group 332), as AutoCAD's
Backgroundgives its id: the object of the OBJECTS section it names; null where it names none.
- Brightness
Gets or sets the brightness of the view (group 141, from R2007), as AutoCAD's
Brightness: -100 to 100; nought where the record gives none.
- CenterPoint
Gets or sets the centre of the viewport on its sheet (groups 10, 20, 30), as AutoCAD's
CenterPoint, in the units of paper space.
- CircleSides
Gets or sets how many sides a circle is drawn with when zoomed (group 72), as AutoCAD's
CircleSides: 1 to 20 000; 100 where the record gives none.
- Contrast
Gets or sets the contrast of the view (group 142, from R2007), as AutoCAD's
Contrast: -100 to 100; nought where the record gives none.
- CustomScale
Gets or sets the scale of the view, as AutoCAD's
CustomScale: the units of the sheet to the units of model space, Height over ViewHeight; 0.02 for a viewport 150 high showing 7 500 of model space.
- DefaultLightingOn
Gets or sets whether the viewport is lit by the default light (group 292, from R2007), as AutoCAD's
DefaultLightingOn; true where the record gives none.
- DefaultLightingType
Gets or sets the default light of the viewport (group 282, from R2007), as AutoCAD's
DefaultLightingType.
- EffectivePlotStyleSheet
Gets the plot style table the viewport is plotted with, as AutoCAD's
EffectivePlotStyleSheet: its own PlotStyleSheet, else that of the layout whose block holds it.
- Elevation
Gets or sets the elevation of the user coordinate system (group 146), as AutoCAD's
Elevation; nought in a file older than R2000.
- FastZoomOn
Gets or sets whether zooming is fast (flag 0x80), as AutoCAD's
FastZoomOn.
- FrontClipAtEyeOn
Gets or sets whether the front clipping plane is at the eye: flag 0x10 (front clip not at eye) clear, as AutoCAD's
FrontClipAtEyeOn.
- FrontClipDistance
Gets or sets how far the front clipping plane is from the target (group 43), as AutoCAD's
FrontClipDistance.
- FrontClipOn
Gets or sets whether the view is clipped in front (flag 2), as AutoCAD's
FrontClipOn.
- GridAdaptive
Gets or sets whether the grid adapts to the zoom (flag 0x80000), as AutoCAD's
GridAdaptive.
- GridBoundToLimits
Gets or sets whether the grid is kept to the limits: flag 0x40000 (grid beyond the limits) clear, as AutoCAD's
GridBoundToLimits.
- GridFollow
Gets or sets whether the grid follows the plane of the user coordinate system (flag 0x200000), as AutoCAD's
GridFollow.
- GridIncrement
Gets or sets the spacing of the grid (groups 15, 25), as AutoCAD's
GridIncrement; 10 by 10 where the record gives none.
- GridMajor
Gets or sets how many lines of the grid one major line is drawn for (group 61, from R2007), as AutoCAD's
GridMajor; 5 where the record gives none.
- GridOn
Gets or sets whether the grid is shown (flag 0x200), as AutoCAD's
GridOn.
- GridSubdivisionRestricted
Gets or sets whether an adaptive grid is kept from dividing below its spacing: flag 0x100000 (divide below the spacing) clear, as AutoCAD's
GridSubdivisionRestricted.
- Height
Gets or sets the height of the viewport on its sheet (group 41), as AutoCAD's
Height.
- HiddenLinesRemoved
Gets or sets whether lines behind faces are hidden when the viewport is plotted (flag 0x800), as AutoCAD's
HiddenLinesRemoved.
- LensLength
Gets or sets the length of the lens of a view in perspective (group 42), as AutoCAD's
LensLength, in millimetres; 50 where the record gives none.
- Locked
Gets or sets whether the view of the viewport is locked against zooming and panning (flag 0x4000 of group 90), as AutoCAD's
Locked.
- NonRectClipEntity
Gets the entity that clips the viewport (group 340), as AutoCAD's
NonRectClipEntityIdnames it: a circle, an ellipse, a closed polyline, a closed spline or a REGION of the same layout, drawn as the border of the viewport. Null for a viewport that is not clipped (NonRectClipOn), one whose boundary the drawing no longer holds, and one of a file older than R2000.
- NonRectClipOn
Gets or sets whether the viewport is clipped by another entity (flag 0x10000 of group 90, the entity group 340), as AutoCAD's
NonRectClipOn; ClipTo(DxfEntity) and RemoveClip() set it with the entity.
- Number
Gets the number of the viewport in its layout, as AutoCAD's
Numbergives it once the layout is shown: the id of group 69 for a viewport that is On, 1 for the viewport that shows the sheet itself and 2 and on for those on it; -1 for a viewport turned off, as AutoCAD 2021 gave its viewport 94 of id 3 turned off, which a file still writes the id of. A viewport made in code is given the next free id of its layout when appended. AutoCAD gives -1 for every viewport of a layout not yet shown as well, which a file does not say: the library reads the layout as shown.
- On
Gets or sets whether the viewport is on, as AutoCAD's
On: its status (group 68) not nought and, from R2000 on, its flag 0x20000 of group 90 clear.
- PerspectiveOn
Gets or sets whether the view is in perspective (flag 1 of group 90; of the view mode of R12), as AutoCAD's
PerspectiveOn.
- PlotAsRaster
Gets whether the viewport is plotted as a raster image, as AutoCAD's
PlotAsRaster: its ShadePlot rendered or a preset of rendering, or a visual style of any type but 2D wireframe, wireframe and hidden (4, 5 and 6), as Realistic or Conceptual; or, plotted as displayed, so shown, by the visual style it is shown in (348), else by its render mode (281) of flat or Gouraud shading. Neither this nor PlotWireframe holds for a viewport plotted with the lines behind hidden.
- PlotStyleSheet
Gets or sets the plot style table of the viewport (group 1), as AutoCAD's
PlotStyleSheet; empty where it has none of its own.
- PlotWireframe
Gets whether the viewport is plotted as wires, as AutoCAD's
PlotWireframe: its ShadePlot wireframe, or a visual style of the drawing it names (group 333) of 2D or 3D wireframe; or, plotted as displayed, so shown: by the visual style it is shown in (348), else by its render mode (281) of 2D optimized or wireframe. A viewport of ezdxf's, plotted as displayed and shown in 2D, is plotted as wires.
- ShadePlot
Gets or sets how the viewport is shaded when plotted (group 170, from R2004), as AutoCAD's
ShadePlot.
- SnapAngle
Gets or sets the angle of the snap, as AutoCAD's
SnapAngle, in radians: group 50, in degrees, from R2000; in radians in the extended data MVIEW of a file of R12 to R14, as the twist is, AutoCAD 2021 writing a snap of 30 degrees there as 0.5235987755982988 (a 30 written there turns the snap by 30 radians).
- SnapBasePoint
Gets or sets the point the snap is laid from (groups 13, 23), as AutoCAD's
SnapBasePoint.
- SnapIncrement
Gets or sets the spacing of the snap (groups 14, 24), as AutoCAD's
SnapIncrement; 10 by 10 where the record gives none.
- SnapIsoPair
Gets or sets the plane of an isometric snap, as AutoCAD's
SnapIsoPair: 0 left, 1 top (flag 0x1000 alone), 2 right (flag 0x2000 alone); both flags read as left.
- SnapIsometric
Gets or sets whether the snap is isometric (flag 0x400), as AutoCAD's
SnapIsometric.
- SnapOn
Gets or sets whether the snap is on (flag 0x100), as AutoCAD's
SnapOn.
- StandardScale
Gets or sets the standard scale of the view, as AutoCAD's
StandardScale: the one whose ratio is CustomScale to within a part in a thousand million, the first in the order of the type where two have it; CustomScale where none has. A file keeps no standard scale of a viewport, so one scaled to fit reads as the scale it was fitted to.
- Sun
Gets the sun the viewport is lit by (group 361, from R2007), as AutoCAD's
SunIdgives its id: the SUN it names; null where it names none, or one the file has not.
- TwistAngle
Gets or sets how far the view is turned about its direction, as AutoCAD's
TwistAngle, in radians: group 51, in degrees, from R2000; in radians in the extended data MVIEW of a file of R12 to R14, as AutoCAD 2021 reads it there (a 30 written there turns the view by 30 radians, 1 718.87 degrees).
- Ucs
Gets or sets the user coordinate system of the viewport, as AutoCAD's
Ucs: its origin (groups 110, 120, 130) and its axes x (111, 121, 131) and y (112, 122, 132), made of unit length; the world's where the record gives none.
- UcsFollowModeOn
Gets or sets whether the view follows the user coordinate system (flag 8), as AutoCAD's
UcsFollowModeOn.
- UcsIconAtOrigin
Gets or sets whether the icon of the user coordinate system stands at its origin (flag 0x40; bit 2 of the R12 icon setting), as AutoCAD's
UcsIconAtOrigin.
- UcsIconVisible
Gets or sets whether the icon of the user coordinate system is shown (flag 0x20; bit 1 of the R12 icon setting), as AutoCAD's
UcsIconVisible.
- UcsName
Gets the name of the named user coordinate system of the viewport (its UCS record, group 345), as AutoCAD's
UcsNamegives its id; null where it is named by none.
- UcsOrthographic
Gets the view along an axis the user coordinate system is of (group 79), as AutoCAD's
UcsOrthographic.
- UcsPerViewport
Gets or sets whether the viewport keeps a user coordinate system of its own (group 71 of 1), as AutoCAD's
UcsPerViewport; false in a file older than R2000.
- ViewCenter
Gets or sets the centre of the view (groups 12, 22), as AutoCAD's
ViewCenter, in the coordinates of the view about its target.
- ViewDirection
Gets or sets the direction from the target to the eye (groups 16, 26, 36), as AutoCAD's
ViewDirection, in world coordinates: (0, 0, 1) for the view from above, which a record that gives none has.
- ViewHeight
Gets or sets the height of model space the viewport shows (group 45), as AutoCAD's
ViewHeight; 1 where the record gives none.
- ViewOrthographic
Gets the view along an axis the viewport shows, as AutoCAD's
ViewOrthographic: TopView where ViewDirection is (0, 0, 1) to Default, and the five others likewise; NonOrthoView for any other direction.
- ViewTarget
Gets or sets the point the view looks at (groups 17, 27, 37), as AutoCAD's
ViewTarget, in world coordinates; the origin where the record gives none.
- Width
Gets or sets the width of the viewport on its sheet (group 40), as AutoCAD's
Width.
Methods
- ClipTo(DxfEntity)
Clips the viewport to a closed entity of its layout, as the VPCLIP command does with an object: the viewport shows model space only inside the boundary, and its frame becomes the box of the boundary, its view kept in place. A viewport 100 by 80 about (100, 100) at 1:2 clipped to a circle of radius 30 about (110, 105) is 60 by 60 about (110, 105), the model point at its centre now the one that lay 10 right and 5 above, 20 and 10 in model units. The boundary stays the entity it is, with the viewport among its reactors (102
{ACAD_REACTORS), as AutoCAD writes it; the boundary the viewport had before stays an entity of the layout, let go. A region is a boundary as it is: one of a ring (a circle of radius 40 less one of 15) makes the frame 80 by 80, the box of its outer loop, and shows nothing in the hole, and one of two squares apart has a frame round both.
- Erase()
Erases the viewport, as Erase() erases an entity, and takes the overrides the layers keep for it out of their extension dictionaries, as AutoCAD does: an XRECORD of overrides left with none goes with its entry. A layout whose last active viewport it was (group 331 of its LAYOUT) names its viewport 1 instead, as AutoCAD 2021 does, or none where it has no other. The viewport of id 1 (group 69) of a layout of paper space, which shows the sheet itself, is refused, as AutoCAD keeps it.
- FitToClip()
Fits the frame of the viewport to the box of its clip boundary again, as AutoCAD does when the boundary is moved, scaled, stretched or turned: the frame is the box of the boundary, and the view keeps its scale and its place, so that a boundary moved 10 to the right takes the viewport 10 to the right showing what it showed. Nothing for a viewport that is not clipped, and nothing where the frame is already the box.
- FreezeLayersInViewport(IEnumerable<DxfLayerTableRecord>)
Freezes layers in the viewport, as AutoCAD's
FreezeLayersInViewport: each not frozen in it yet named after those that are, by its handle (331), or by its name in the extended data of a file older than R2000; nothing where all are.
- GetFrozenLayers()
Gets the layers frozen in the viewport, as AutoCAD's
GetFrozenLayersgives their ids: those its groups 331 name by handle (341 in a DXF of R2000, the names of its extended data in a file older than R2000) that the layer table has, in their order.
- GetUcs(out GeoPoint3, out GeoVector3, out GeoVector3)
Gives the user coordinate system of the viewport as the record holds it, as AutoCAD's
GetUcs: its origin and its axes x and y, not made of unit length; the world's where the record gives none, or its axes are of no length or along one line.
- IsLayerFrozenInViewport(DxfLayerTableRecord)
Gets whether a layer is frozen in the viewport, as AutoCAD's
IsLayerFrozenInViewport.
- RemoveClip()
Takes the clip off the viewport, as the Delete of VPCLIP does: the boundary is erased, the link and the flag go, and the frame stays the box the boundary had. Nothing for a viewport that is not clipped.
- SetShadePlot(DxfShadePlotType, DxfDBObject)
Sets how the viewport is shaded when plotted, as AutoCAD's
SetShadePlot: the type (group 170) and the visual style or preset of rendering it names (333), taken out for a type that names none.
- SetSun(DxfSun)
Lights the viewport by a sun, as AutoCAD's
SetSun: the sun made in code written at the end of the OBJECTS section, owned by the viewport, which names it (group 361), and the class SUN listed in the CLASSES section where it is not; the sun it had erased where the viewport owned it, as AutoCAD erases the old sun, and kept where another owns it.viewport.SetSun(new DxfSun { Intensity = 1.5 })gives a viewport AutoCAD's sun half as bright again.
- SetUcs(DxfOrthographicView)
Gives the viewport the user coordinate system of a view along an axis, as AutoCAD's
SetUcsof anOrthographicView: about the world's origin, its plane that of the view, top (x along x, y along y), bottom (x, -y), front (x, z), back (-x, z), left (-y, z) or right (y, z); its view written (79), its base the world (346 taken out).
- SetUcs(GeoPoint3, GeoVector3, GeoVector3)
Gives the viewport a user coordinate system of its own, as AutoCAD's
SetUcsof an origin and two axes: they are written as given, the system named by none (345 and 346 taken out) and along no axis (79 of 0).
- SetUcsToWorld()
Gives the viewport the world's coordinate system, as AutoCAD's
SetUcsToWorld: as SetUcs(GeoPoint3, GeoVector3, GeoVector3) of the origin and the axes x and y.
- SetViewDirection(DxfOrthographicView)
Points the view along an axis, as AutoCAD's
SetViewDirection: from above (0, 0, 1), below (0, 0, -1), the front (0, -1, 0), the back (0, 1, 0), the left (-1, 0, 0) or the right (1, 0, 0).
- ThawAllLayersInViewport()
Thaws every layer in the viewport, as AutoCAD's
ThawAllLayersInViewport; nothing where none is frozen in it.
- ThawLayersInViewport(IEnumerable<DxfLayerTableRecord>)
Thaws layers in the viewport, as AutoCAD's
ThawLayersInViewport; nothing for one not frozen in it.
- ToString()
Gives the viewport as a line for debugging: its type, handle, id and size.