Layout Manager

The layout manager is unique to each DXF drawing, access the layout manager as layouts attribute of the Drawing object.

class ezdxf.layouts.Layouts

The Layouts class manages Paperspace layouts and the Modelspace.

__len__() → int

Returns count of existing layouts, including the modelspace layout.

__contains__(name: str) → bool

Returns True if layout name exist.

__iter__() → Iterable[Layout]

Returns iterable of all layouts as Layout objects, including the modelspace layout.

names() → List[str]

Returns a list of all layout names, all names in original case sensitive form.

names_in_taborder() → List[str]

Returns all layout names in tab order as shown in CAD applications.

modelspace() → Modelspace

Returns the Modelspace layout.

get(name: str) → Layout

Returns Layout by name, case insensitive “Model” == “MODEL”.

Parameters

name – layout name as shown in tab, e.g. 'Model' for modelspace

new(name: str, dxfattribs: dict = None) → Paperspace

Returns a new Paperspace layout.

Parameters
  • name – layout name as shown in tabs in CAD applications

  • dxfattribs – additional DXF attributes for the DXFLayout entity

Raises
  • DXFValueError – Invalid characters in layout name.

  • DXFValueError – Layout name already exist.

rename(old_name: str, new_name: str) → None

Rename a layout from old_name to new_name. Can not rename layout 'Model' and the new name of a layout must not exist.

Parameters
  • old_name – actual layout name, case insensitive

  • new_name – new layout name, case insensitive

Raises
  • DXFValueError – try to rename 'Model'

  • DXFValueError – Layout new_name already exist.

delete(name: str) → None

Delete layout name and destroy all entities in that layout.

Parameters

name (str) – layout name as shown in tabs

Raises
  • DXFKeyError – if layout name do not exists

  • DXFValueError – deleting modelspace layout is not possible

  • DXFValueError – deleting last paperspace layout is not possible

active_layout() → Paperspace

Returns the active paperspace layout.

set_active_layout(name: str) → None

Set layout name as active paperspace layout.

get_layout_for_entity(entity: DXFEntity) → Layout

Returns the owner layout for a DXF entity.