Add Layouts And Blocks¶
Layouts are containers for DXF entities like LINE or CIRCLE. There exist three layouts types:
Modelspace¶
The Modelspace
is unique.
It is not possible to create another one.
Paperspace Layout¶
All DXF versions can have multiple paperspace layouts expect DXF R12.
Add a new paperspace layout to a DXF document:
doc.layouts.new("MyLayout")
The layout name is the name shown on the tab in CAD applications and has to be unique,
otherwise a DXFValueError
will be raised.
It is possible to add multiple paperspace layouts to all DXF versions, but ezdxf
exports for DXF R12 only the active paperspace layout. Any paperspace layout can be
set as the active paperspace layout by the method: ezdxf.layouts.Layouts.set_active_layout()
.
Block Definition¶
Add a new block definition to a DXF document:
doc.blocks.new("MyLayout")
The block name has to be unique, otherwise a DXFValueError
will be raised.
Add an anonymous block definition:
my_block = doc.blocks.new_anonymous_block()
# store the block name, so you can create block references to this block
block_name = my_block.name
Anonymous blocks are used internally and do not show up in the insert dialog for block references in CAD applications.
See also
Tasks:
Tutorials:
Basics:
Classes:
ezdxf.layouts.BaseLayout
- parent of all layoutsezdxf.layouts.Layout
- parent of modelspace & paperspaceezdxf.layouts.Layouts
- layout manager (Drawing.layouts
attribute)ezdxf.sections.blocks.BlocksSection
- blocks manager (Drawing.blocks
attribute)