Zoom Layouts

New in version 0.16.

These functions mimic the ZOOM commands in CAD applications.

Zooming means resetting the current viewport limits to new values. The coordinates for the functions center() and window() are drawing units for the model space and paper space units for paper space layouts. The modelspace units in Drawing.units are ignored.

The extents detection for the functions entities() and extents() is done by the ezdxf.bbox module. Read the associated documentation to understand the limitations of the ezdxf.bbox module. Tl;dr The extents detection is slow and not accurate.

Because the ZOOM operations in CAD applications are not that precise, then zoom functions of this module uses the fast bounding box calculation mode of the bbox module, which means the argument flatten is always False for extents() function calls.

The region displayed by CAD applications also depends on the aspect ratio of the application window, which is not available to ezdxf, therefore the viewport size is just an educated guess of an aspect ratio of 2:1 (16:9 minus top toolbars and the bottom status bar).

Warning

All zoom functions replace the current viewport configuration by a single window configuration.

Example to reset the main CAD viewport of the model space to the extents of its entities:

import ezdxf
from ezdxf import zoom

doc = ezdxf.new()
msp = doc.modelspace()
... # add your DXF entities

zoom.extents(msp)
doc.saveas("your.dxf")
ezdxf.zoom.center(layout: Layout, point: Vertex, height: float)

Resets the active viewport center of layout to the given point, argument size defines the width and height of the viewport. Replaces the current viewport configuration by a single window configuration.

ezdxf.zoom.objects(layout: Layout, entities: Iterable[DXFEntity], factor: float = 1)

Resets the active viewport limits of layout to the extents of the given entities. Only entities in the given layout are taken into account. The argument factor scales the viewport limits. Replaces the current viewport configuration by a single window configuration.

ezdxf.zoom.extents(layout: Layout, factor: float = 1)

Resets the active viewport limits of layout to the extents of all entities in this layout. The argument factor scales the viewport limits. Replaces the current viewport configuration by a single window configuration.

ezdxf.zoom.window(layout: Layout, p1: Vertex, p2: Vertex)

Resets the active viewport limits of layout to the lower left corner p1 and the upper right corner p2. Replaces the current viewport configuration by a single window configuration.