1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
|
.. include:: ../spline-links.inc
.. _layout:
Layout Types
============
.. module:: ezdxf.layouts
:noindex:
A Layout represents and manages DXF entities, there are three different layout objects:
- :class:`Modelspace` is the common working space, containing basic drawing entities.
- :class:`Paperspace` is arrangement of objects for printing and plotting, this layout contains basic drawing entities
and viewports to the :class:`Modelspace`.
- :class:`BlockLayout` works on an associated :class:`~ezdxf.entities.block.Block`, Blocks are collections of drawing
entities for reusing by block references.
.. warning::
Do not instantiate layout classes by yourself - always use the provided factory functions!
Entity Ownership
----------------
A layout owns all entities residing in their entity space, this means the :attr:`dxf.owner` attribute of
any :class:`~ezdxf.entities.dxfgfx.DXFGraphic` in this layout is the :attr:`dxf.handle` of the layout, and deleting
an entity from a layout is the end of life of this entity, because it is also deleted from the
:class:`~ezdxf.entitydb.EntityDB`.
But it is possible to just unlink an entity from a layout, so it can be assigned to another layout, use the
:meth:`~BaseLayout.move_to_layout` method to move entities between layouts.
BaseLayout
==========
.. class:: BaseLayout
:class:`BaseLayout` is the common base class for :class:`Layout` and :class:`BlockLayout`.
.. autoattribute:: is_alive
.. autoattribute:: is_active_paperspace
.. autoattribute:: is_any_paperspace
.. autoattribute:: is_modelspace
.. autoattribute:: is_any_layout
.. autoattribute:: is_block_layout
.. autoattribute:: units
.. automethod:: __len__
.. automethod:: __iter__
.. automethod:: __getitem__
.. automethod:: get_extension_dict
.. automethod:: delete_entity
.. automethod:: delete_all_entities
.. automethod:: unlink_entity
.. automethod:: purge
.. automethod:: query
.. automethod:: groupby
.. automethod:: move_to_layout
.. automethod:: set_redraw_order
.. automethod:: get_redraw_order
.. automethod:: entities_in_redraw_order
.. automethod:: add_entity
.. automethod:: add_foreign_entity
.. automethod:: add_point
.. automethod:: add_line
.. automethod:: add_circle
.. automethod:: add_ellipse
.. automethod:: add_arc
.. automethod:: add_solid
.. automethod:: add_trace
.. automethod:: add_3dface
.. automethod:: add_text
.. automethod:: add_blockref
.. automethod:: add_auto_blockref
.. automethod:: add_attdef
.. automethod:: add_polyline2d
.. automethod:: add_polyline3d
.. automethod:: add_polymesh
.. automethod:: add_polyface
.. automethod:: add_shape
.. automethod:: add_lwpolyline
.. automethod:: add_mtext
.. automethod:: add_mtext_static_columns
.. automethod:: add_mtext_dynamic_manual_height_columns
.. automethod:: add_mtext_dynamic_auto_height_columns
.. automethod:: add_ray
.. automethod:: add_xline
.. automethod:: add_mline
.. automethod:: add_spline
.. automethod:: add_cad_spline_control_frame
.. automethod:: add_spline_control_frame
.. automethod:: add_open_spline
.. automethod:: add_rational_spline
.. automethod:: add_hatch
.. automethod:: add_helix
.. automethod:: add_mpolygon
.. automethod:: add_mesh
.. automethod:: add_image
.. automethod:: add_wipeout
.. automethod:: add_underlay
.. automethod:: add_linear_dim
.. automethod:: add_multi_point_linear_dim
.. automethod:: add_aligned_dim
.. automethod:: add_radius_dim
.. automethod:: add_radius_dim_2p
.. automethod:: add_radius_dim_cra
.. automethod:: add_diameter_dim
.. automethod:: add_diameter_dim_2p
.. automethod:: add_angular_dim_2l
.. automethod:: add_angular_dim_3p
.. automethod:: add_angular_dim_cra
.. automethod:: add_angular_dim_arc
.. automethod:: add_arc_dim_3p
.. automethod:: add_arc_dim_cra
.. automethod:: add_arc_dim_arc
.. automethod:: add_ordinate_dim
.. automethod:: add_ordinate_x_dim
.. automethod:: add_ordinate_y_dim
.. automethod:: add_leader
.. automethod:: add_multileader_mtext
.. automethod:: add_multileader_block
.. automethod:: add_body
.. automethod:: add_region
.. automethod:: add_3dsolid
.. automethod:: add_surface
.. automethod:: add_extruded_surface
.. automethod:: add_lofted_surface
.. automethod:: add_revolved_surface
.. automethod:: add_swept_surface
Layout
======
.. class:: Layout
:class:`Layout` is a subclass of :class:`BaseLayout` and common base class of :class:`Modelspace` and
:class:`Paperspace`.
.. autoattribute:: name
.. autoattribute:: dxf
.. automethod:: __contains__
.. automethod:: reset_extents
.. automethod:: reset_limits
.. automethod:: set_plot_type
.. automethod:: set_plot_style
.. automethod:: set_plot_window
.. automethod:: plot_viewport_borders
.. automethod:: show_plot_styles
.. automethod:: plot_centered
.. automethod:: plot_hidden
.. automethod:: use_standard_scale
.. automethod:: use_plot_styles
.. automethod:: scale_lineweights
.. automethod:: print_lineweights
.. automethod:: draw_viewports_first
.. automethod:: model_type
.. automethod:: update_paper
.. automethod:: zoom_to_paper_on_update
.. automethod:: plot_flags_initializing
.. automethod:: prev_plot_init
.. automethod:: set_plot_flags
Modelspace
==========
.. class:: Modelspace
:class:`Modelspace` is a subclass of :class:`Layout`.
The modelspace contains the "real" world representation of the drawing subjects in real world units.
.. autoattribute:: name
.. automethod:: new_geodata
.. automethod:: get_geodata
Paperspace
==========
.. class:: Paperspace
:class:`Paperspace` is a subclass of :class:`Layout`.
Paperspace layouts are used to create different drawing sheets of the modelspace subjects for printing or
PDF export.
.. autoattribute:: name
.. automethod:: page_setup(size=(297, 210), margins=(10, 15, 10, 15), units='mm', offset=(0, 0), rotation=0, scale=16, name='ezdxf', device='DWG to PDF.pc3')
.. automethod:: viewports
.. automethod:: main_viewport
.. automethod:: add_viewport
.. automethod:: reset_viewports
.. automethod:: reset_main_viewport
.. automethod:: reset_paper_limits
.. automethod:: get_paper_limits
BlockLayout
===========
.. class:: BlockLayout
:class:`BlockLayout` is a subclass of :class:`BaseLayout`.
Block layouts are reusable sets of graphical entities, which can be referenced by multiple
:class:`~ezdxf.entities.Insert` entities. Each reference can be placed, scaled and rotated individually and can
have it's own set of DXF :class:`~ezdxf.entities.Attrib` entities attached.
.. autoproperty:: name
.. autoproperty:: block
.. autoproperty:: endblk
.. autoproperty:: dxf
.. autoproperty:: can_explode
.. autoproperty:: scale_uniformly
.. autoproperty:: base_point
.. automethod:: __contains__
.. automethod:: attdefs
.. automethod:: has_attdef
.. automethod:: get_attdef
.. automethod:: get_attdef_text
.. _limits: https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2020/ENU/AutoCAD-Core/files/GUID-6CF82FC7-E1BC-4A8C-A23D-4396E3D99632-htm.html
.. _extents: https://knowledge.autodesk.com/de/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2020/DEU/AutoCAD-Core/files/GUID-B3926CFA-DE74-4661-A9A5-2738A1FD937B-htm.html
|