Viewport
The VIEWPORT entity (DXF Reference) is a window from a paperspace layout to the modelspace.
Subclass of |
|
DXF type |
|
Factory function |
|
Inherited DXF attributes |
Warning
Do not instantiate entity classes by yourself - always use the provided factory functions!
- class ezdxf.entities.Viewport
- dxf.center
Center point of the viewport located in the paper space layout in paper space units stored as 3D point. (Error in the DXF reference)
- dxf.width
Viewport width in paperspace units (float)
- dxf.height
Viewport height in paperspace units (float)
- dxf.status
Viewport status field (int)
-1
On, but is fully off screen, or is one of the viewports that is not active because the $MAXACTVP count is currently being exceeded.
0
Off
>0
On and active. The value indicates the order of stacking for the viewports, where 1 is the active viewport, 2 is the next, and so forth.
- dxf.id
Viewport id (int)
- dxf.view_center_point
View center point in modelspace stored as 2D point, but represents a WCS point. (Error in the DXF reference)
- dxf.snap_base_point
- dxf.snap_spacing
- dxf.snap_angle
- dxf.grid_spacing
- dxf.perspective_lens_length
Lens focal length in mm as 35mm film equivalent.
- dxf.front_clip_plane_z_value
- dxf.back_clip_plane_z_value
- dxf.view_twist_angle
- dxf.circle_zoom
- dxf.flags
Viewport status bit-coded flags:
Bit value
Constant in
ezdxf.const
Description
1 (0x1)
VSF_PERSPECTIVE_MODE
Enables perspective mode
2 (0x2)
VSF_FRONT_CLIPPING
Enables front clipping
4 (0x4)
VSF_BACK_CLIPPING
Enables back clipping
8 (0x8)
VSF_USC_FOLLOW
Enables UCS follow
16 (0x10)
VSF_FRONT_CLIPPING_NOT_AT_EYE
Enables front clip not at eye
32 (0x20)
VSF_UCS_ICON_VISIBILITY
Enables UCS icon visibility
64 (0x40)
VSF_UCS_ICON_AT_ORIGIN
Enables UCS icon at origin
128 (0x80)
VSF_FAST_ZOOM
Enables fast zoom
256 (0x100)
VSF_SNAP_MODE
Enables snap mode
512 (0x200)
VSF_GRID_MODE
Enables grid mode
1024 (0x400)
VSF_ISOMETRIC_SNAP_STYLE
Enables isometric snap style
2048 (0x800)
VSF_HIDE_PLOT_MODE
Enables hide plot mode
4096 (0x1000)
VSF_KISOPAIR_TOP
kIsoPairTop. If set and kIsoPairRight is not set, then isopair top is enabled. If both kIsoPairTop and kIsoPairRight are set, then isopair left is enabled
8192 (0x2000)
VSF_KISOPAIR_RIGHT
kIsoPairRight. If set and kIsoPairTop is not set, then isopair right is enabled
16384 (0x4000)
VSF_LOCK_ZOOM
Enables viewport zoom locking
32768 (0x8000)
VSF_CURRENTLY_ALWAYS_ENABLED
Currently always enabled
65536 (0x10000)
VSF_NON_RECTANGULAR_CLIPPING
Enables non-rectangular clipping
131072 (0x20000)
VSF_TURN_VIEWPORT_OFF
Turns the viewport off
262144 (0x40000)
VSF_NO_GRID_LIMITS
Enables the display of the grid beyond the drawing limits
524288 (0x80000)
VSF_ADAPTIVE_GRID_DISPLAY
Enable adaptive grid display
1048576 (0x100000)
VSF_SUBDIVIDE_GRID
Enables subdivision of the grid below the set grid spacing when the grid display is adaptive
2097152 (0x200000)
VSF_GRID_FOLLOW_WORKPLANE
Enables grid follows workplane switching
Use helper method
set_flag_state()
to set and clear viewport flags, e.g. lock viewport:vp.set_flag_state(ezdxf.const.VSF_LOCK_ZOOM, True)
- dxf.clipping_boundary_handle
- dxf.plot_style_name
- dxf.render_mode
0
2D Optimized (classic 2D)
1
Wireframe
2
Hidden line
3
Flat shaded
4
Gouraud shaded
5
Flat shaded with wireframe
6
Gouraud shaded with wireframe
- dxf.ucs_per_viewport
- dxf.ucs_icon
- dxf.ucs_origin
UCS origin as 3D point.
- dxf.ucs_x_axis
UCS x-axis as 3D vector.
- dxf.ucs_y_axis
UCS y-axis as 3D vector.
- dxf.ucs_handle
Handle of
UCSTable
if UCS is a named UCS. If not present, then UCS is unnamed.
- dxf.ucs_ortho_type
0
not orthographic
1
Top
2
Bottom
3
Front
4
Back
5
Left
6
Right
- dxf.ucs_base_handle
Handle of
UCSTable
of base UCS if UCS is orthographic (Viewport.dxf.ucs_ortho_type
is non-zero). If not present andViewport.dxf.ucs_ortho_type
is non-zero, then base UCS is taken to be WORLD.
- dxf.elevation
- dxf.shade_plot_mode
(DXF R2004)
0
As Displayed
1
Wireframe
2
Hidden
3
Rendered
- dxf.grid_frequency
Frequency of major grid lines compared to minor grid lines. (DXF R2007)
- dxf.background_handle
- dxf.shade_plot_handle
- dxf.visual_style_handle
- dxf.default_lighting_flag
- dxf.default_lighting_style
0
One distant light
1
Two distant lights
- dxf.view_brightness
- dxf.view_contrast
- dxf.ambient_light_color_1
- dxf.ambient_light_color_2
as true color value
- dxf.ambient_light_color_3
as true color value
- dxf.sun_handle
- dxf.ref_vp_object_1
- dxf.ref_vp_object_2
- dxf.ref_vp_object_3
- dxf.ref_vp_object_4
- frozen_layers
Set/get frozen layers as list of layer names.
- is_frozen(layer_name: str) bool
Returns
True
if layer_name id frozen in this viewport.
- freeze(layer_name: str) None
Freeze layer_name in this viewport.
- thaw(layer_name: str) None
Thaw layer_name in this viewport.
- has_extended_clipping_path
Returns
True
if a non-rectangular clipping path is defined.
- clipping_rect() tuple[Vec2, Vec2]
Returns the lower left and the upper right corner of the clipping rectangle in paperspace coordinates.
- clipping_rect_corners() list[Vec2]
Returns the default rectangular clipping path as list of vertices. Use function
ezdxf.path.make_path()
to get also non-rectangular shaped clipping paths if defined.
- get_aspect_ratio() float
Returns the aspect ratio of the viewport, return 0.0 if width or height is zero.
- get_modelspace_limits() tuple[float, float, float, float]
Returns the limits of the modelspace to view in drawing units as tuple (min_x, min_y, max_x, max_y).
- get_scale() float
Returns the scaling factor from modelspace to viewport.