VIEWPORT (Table Entry)

A viewport is a windows containing a view to the drawing model. You can change the default view, which will be displayed on opening the drawing with a CAD program, by adding a viewport named '*ACTIVE'. In AutoCAD you can place multiple viewports in the main editor window (Left, Right, Top), but don’t ask me how to do this in a DXF file.

Create a viewport:

drawing.add_vport(name, ...)

is a shortcut for:

vport = DXFEngine.vport(name, ...)
drawing.viewports.add(vport)
DXFEngine.vport(name, **kwargs)
Parameters:
  • name (str) – viewport name
  • flags (int) – standard flag values, bit-coded, default=0
  • lower_left – lower-left corner of viewport, (xy-tuple), default=(0, 0)
  • upper_right – upper-right corner of viewport, (xy-tuple), default=(1, 1)
  • center_point – view center point, in WCS, (xy-tuple), default=(.5, .5)
  • snap_base – snap base point, (xy-tuple), default=(0, 0)
  • snap_spacing – snap spacing, X and Y (xy-tuple), default=(.1, .1)
  • grid_spacing – grid spacing, X and Y (xy-tuple), default=(.1, .1)
  • direction_point – view direction from target point (xyz-tuple), default=(0, 0, 1)
  • target_point – view target point (xyz-tuple), default=(0, 0, 0)
  • aspect_ratio – viewport aspect ratio (float), default=1.
  • lens_length (float) – lens length, default=50
  • front_clipping (float) – front and back clipping planes, offsets from target point , default=0
  • back_clipping (float) – see front_clipping
  • view_twist (float) – twist angle in degree, default=0
  • circle_zoom (float) – circle zoom percent, default=100
  • view_mode (int) – view mode, bit-coded, default=0
  • fast_zoom (int) – fast zoom setting, default=1
  • ucs_icon (int) – UCSICON settings, default=3
  • snap_on (int) – snap on/off, default=0
  • grid_on (int) – grid on/off, default=0
  • snap_style (int) – snap style, default=0
  • snap_isopair (int) – snap isopair, default=0

View Mode Flags

Flags Description
VMODE_TURNED_OFF viewport is turned off if bit is set
VMODE_PERSPECTIVE_VIEW_ACTIVE viewport is in perspective mode if bit is set
VMODE_FRONT_CLIPPING_ON front clipping is on if bit is set
VMODE_BACK_CLIPPING_ON back clipping is on if bit is set
VMODE_UCS_FOLLOW_MODE_ON ???
VMODE_FRONT_CLIP_NOT_AT_EYE ???