File: layout_management.rst

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (377 lines) | stat: -rw-r--r-- 14,721 bytes parent folder | download | duplicates (3)
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
.. _Layout Management Structures:

Layout Management Structures
============================

Layouts are separated entity spaces, there are three different Layout types:

    1. modelspace contains the 'real' world representation of the drawing
       subjects in real world units.
    2. paperspace layouts are used to create different drawing sheets of the
       modelspace subjects for printing or PDF export
    3. Blocks are reusable sets of graphical entities, inserted/referenced
       by the INSERT entity.

All layouts have at least a BLOCK definition in the BLOCKS section and since
DXF R13 exist the BLOCK_RECORD table with an entry for every BLOCK in the
BLOCKS section.

.. seealso::

    Information about :ref:`Block Management Structures`


The name of the modelspace BLOCK is "\*Model_Space" (DXF R12: "$MODEL_SPACE")
and the name of the `active` paperspace BLOCK is "\*Paper_Space"
(DXF R12: "$PAPER_SPACE"), the entities of these two layouts are
stored in the ENTITIES section, DXF R12 supports just one paperspace layout.

DXF R13+ supports multiple paperspace layouts, the `active` layout is still
called "\*Paper_Space", the additional `inactive` paperspace layouts are named
by the scheme "\*Paper_Spacennnn", where the first inactive paper space is
called "\*Paper_Space0", the second "\*Paper_Space1" and so on.
A none consecutive numbering is tolerated by AutoCAD. The content of the
inactive paperspace layouts are stored as BLOCK content in the BLOCKS section.
These names are just the DXF internal layout names, each layout has an
additional layout name which is displayed to the user by the CAD application.

A BLOCK definition and a BLOCK_RECORD is not enough for a proper layout setup,
an LAYOUT entity in the OBJECTS section is also required. All LAYOUT entities
are managed by a DICTIONARY entity, which is referenced as "ACAD_LAYOUT"
entity in the root DICTIONARY of the DXF file.

.. note::

    All floating point values are rounded to 2 decimal places for better
    readability.


LAYOUT Entity
-------------

Since DXF R2000 modelspace and paperspace layouts require the DXF
`LAYOUT <http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-433D25BF-655D-4697-834E-C666EDFD956D>`_ entity.

.. code-block:: none

    0
    LAYOUT
    5       <<< handle
    59
    102     <<< extension dictionary (ignore)
    {ACAD_XDICTIONARY
    360
    1C3
    102
    }
    102     <<< reactor (required?)
    {ACAD_REACTORS
    330
    1A      <<< pointer to "ACAD_LAYOUT" DICTIONARY (layout management table)
    102
    }
    330     <<< owner handle
    1A      <<< pointer to "ACAD_LAYOUT" DICTIONARY (same as reactor pointer)
    100     <<< PLOTSETTINGS
    AcDbPlotSettings
    1       <<< page setup name

    2       <<< name of system printer or plot configuration file
    none_device
    4       <<< paper size, part in braces should follow the schema
    ...     (width_x_height_unit) unit is 'Inches' or 'MM'
    ...     Letter\_(8.50_x_11.00_Inches)  the part in front of the braces is
    ...     ignored by AutoCAD
    6       <<< plot view name

    40      <<< size of unprintable margin on left side of paper in millimeters,
    ...     defines also the plot origin-x
    6.35
    41      <<< size of unprintable margin on bottom of paper in millimeters,
    ...     defines also the plot origin-y
    6.35
    42      <<< size of unprintable margin on right side of paper in millimeters
    6.35
    43      <<< size of unprintable margin on top of paper in millimeters
    6.35
    44      <<< plot paper size: physical paper width in millimeters
    215.90
    45      <<< plot paper size: physical paper height in millimeters
    279.40
    46      <<< X value of plot origin offset in millimeters, moves the plot origin-x
    0.0
    47      <<< Y value of plot origin offset in millimeters, moves the plot origin-y
    0.0
    48      <<< plot window area: X value of lower-left window corner
    0.0
    49      <<< plot window area: Y value of lower-left window corner
    0.0
    140     <<< plot window area: X value of upper-right window corner
    0.0
    141     <<< plot window area: Y value of upper-right window corner
    0.0
    142     <<< numerator of custom print scale: real world (paper) units, 1.0
    ...     for scale 1:50
    1.0
    143     <<< denominator of custom print scale: drawing units, 50.0
    ...     for scale 1:50
    1.0
    70      <<< plot layout flags, bit-coded (... too many options)
    688     <<< b1010110000 = UseStandardScale(16)/PlotPlotStyle(32)
    ...     PrintLineweights(128)/DrawViewportsFirst(512)
    72      <<< plot paper units (0/1/2 for inches/millimeters/pixels), are
    ...     pixels really supported?
    0
    73      <<< plot rotation (0/1/2/3 for 0deg/90deg counter-cw/upside-down/90deg cw)
    1       <<< 90deg clockwise
    74      <<< plot type 0-5 (... too many options)
    5       <<< 5 = layout information
    7       <<< current plot style name, e.g. 'acad.ctb' or 'acadlt.ctb'

    75      <<< standard scale type 0-31 (... too many options)
    16      <<< 16 = 1:1, also 16 if user scale type is used
    147     <<< unit conversion factor
    1.0     <<< for plot paper units in mm, else  0.03937... (1/25.4) for inches
    ...     as plot paper units
    76      <<< shade plot mode (0/1/2/3 for as displayed/wireframe/hidden/rendered)
    0       <<< as displayed
    77      <<< shade plot resolution level 1-5 (... too many options)
    2       <<< normal
    78      <<< shade plot custom DPI: 100-32767, Only applied when shade plot
    ...     resolution level is set to 5 (Custom)
    300
    148     <<< paper image origin: X value
    0.0
    149     <<< paper image origin: Y value
    0.0
    100     <<< LAYOUT settings
    AcDbLayout
    1       <<< layout name
    Layout1
    70      <<< flags bit-coded
    1       <<< 1 = Indicates the PSLTSCALE value for this layout when this
    ...     layout is current
    71      <<< Tab order ("Model" tab always appears as the first tab
    ...     regardless of its tab order)
    1
    10      <<< minimum limits for this layout (defined by LIMMIN while this
    ...     layout is current)
    -0.25   <<<     x value, distance of the left paper margin from the plot
    ...     origin-x, in plot paper units and by scale (e.g. x50 for 1:50)
    20      <<<     group code for y value
    -0.25   <<<     y value, distance of the bottom paper margin from the plot
    ...     origin-y, in plot paper units and by scale (e.g. x50 for 1:50)
    11      <<< maximum limits for this layout (defined by LIMMAX while this
    ...     layout is current)
    10.75   <<<     x value, distance of the right paper margin from the plot
    ...     origin-x, in plot paper units and by scale (e.g. x50 for 1:50)
    21      <<<     group code for y value
    8.25    <<<     y value, distance of the top paper margin from the plot
    ...     origin-y, in plot paper units and by scale (e.g. x50 for 1:50)
    12      <<< insertion base point for this layout (defined by INSBASE while
    ...     this layout is current)
    0.0     <<<     x value
    22      <<<     group code for y value
    0.0     <<<     y value
    32      <<<     group code for z value
    0.0     <<<     z value
    14      <<< minimum extents for this layout (defined by EXTMIN while this
    ...     layout is current), AutoCAD default is (1e20, 1e20, 1e20)
    1.05    <<<     x value
    24      <<<     group code for y value
    0.80    <<<     y value
    34      <<<     group code for z value
    0.0     <<<     z value
    15      <<< maximum extents for this layout (defined by EXTMAX while this
    ...     layout is current), AutoCAD default is (-1e20, -1e20, -1e20)
    9.45    <<<     x value
    25      <<<     group code for y value
    7.20    <<<     y value
    35      <<<     group code for z value
    0.0     <<<     z value
    146     <<< elevation ???
    0.0
    13      <<< UCS origin (3D Point)
    0.0     <<<     x value
    23      <<<     group code for y value
    0.0     <<<     y value
    33      <<<     group code for z value
    0.0     <<<     z value
    16      <<< UCS X-axis (3D vector)
    1.0     <<<     x value
    26      <<<     group code for y value
    0.0     <<<     y value
    36      <<<     group code for z value
    0.0     <<<     z value
    17      <<< UCS Y-axis (3D vector)
    0.0     <<<     x value
    27      <<<     group code for y value
    1.0     <<<     y value
    37      <<<     group code for z value
    0.0     <<<     z value
    76      <<< orthographic type of UCS 0-6 (... too many options)
    0       <<< 0 = UCS is not orthographic ???
    330     <<< ID/handle of required block table record
    58
    331     <<< ID/handle to the viewport that was last active in this layout
    ...     when the layout was current
    1B9
    1001    <<< extended data (ignore)
    ...

And as it seems this is also not enough for a well defined LAYOUT, at least a
"main" VIEWPORT entity with ID=1 is required for paperspace layouts, located in
the entity space of the layout.

The modelspace layout requires (?) a VPORT entity in the VPORT table (group code
331 in the AcDbLayout subclass).

Main VIEWPORT Entity for LAYOUT
-------------------------------

The "main" viewport for layout "Layout1" shown above. This viewport is located
in the associated BLOCK definition called "\*Paper_Space0". Group code 330 in
subclass AcDbLayout points to the BLOCK_RECORD of "\*Paper_Space0".

Remember: the entities of the `active` paperspace layout are located in the
ENTITIES section, therefore "Layout1" is not the active paperspace layout.

The "main" VIEWPORT describes, how the application shows the paperspace layout
on the screen, and I guess only AutoCAD needs this values.

.. image:: gfx/main_viewport.jpg
    :align: center

.. code-block:: none

    0
    VIEWPORT
    5       <<< handle
    1B4
    102     <<< extension dictionary (ignore)
    {ACAD_XDICTIONARY
    360
    1B5
    102
    }
    330     <<< owner handle
    58      <<< points to BLOCK_RECORD (same as group code 330 in AcDbLayout of
    ...     "Layout1")
    100
    AcDbEntity
    67      <<< paperspace flag
    1       <<< 0 = modelspace; 1 = paperspace
    8       <<< layer,
    0
    100
    AcDbViewport
    10      <<< Center point (in WCS)
    5.25    <<<     x value
    20      <<<     group code for y value
    4.00    <<<     y value
    30      <<<     group code for z value
    0.0     <<<     z value
    40      <<< width in paperspace units
    23.55   <<< VIEW size in AutoCAD, depends on the workstation configuration
    41      <<< height in paperspace units
    9.00    <<< VIEW size in AutoCAD, depends on the workstation configuration
    68      <<< viewport status field -1/0/n
    2       <<< >0  On and active. The value indicates the order of stacking for
    ...     the viewports, where 1 is the active viewport, 2 is the next, and so forth
    69      <<< viewport ID
    1       <<< "main" viewport has always ID=1
    12      <<< view center point in Drawing Coordinate System (DCS), defines
    ...     the center point of the VIEW in relation to the LAYOUT origin
    5.25    <<<     x value
    22      <<<     group code for y value
    4.00    <<<     y value
    13      <<< snap base point in modelspace
    0.0     <<<     x value
    23      <<<     group code for y value
    0.0     <<<     y value
    14      <<< snap spacing in modelspace units
    0.5     <<<     x value
    24      <<<     group code for y value
    0.5     <<<     y value
    15      <<< grid spacing in modelspace units
    0.5     <<<     x value
    25      <<<     group code for y value
    0.5     <<<     y value
    16      <<< view direction vector from target (in WCS)
    0.0     <<<     x value
    26      <<<     group code for y value
    0.0     <<<     y value
    36      <<<     group code for z value
    1.0     <<<     z value
    17      <<< view target point
    0.0     <<<     x value
    27      <<<     group code for y value
    0.0     <<<     y value
    37      <<<     group code for z value
    0.0     <<<     z value
    42      <<<     perspective lens length, focal length?
    50.0    <<<     50mm
    43      <<<     front clip plane z value
    0.0     <<<     z value
    44      <<<     back clip plane z value
    0.0     <<<     z value
    45      <<<     view height (in modelspace units)
    9.00
    50      <<< snap angle
    0.0
    51      <<< view twist angle
    0.0
    72      <<< circle zoom percent
    1000
    90      <<< Viewport status bit-coded flags (... too many options)
    819232  <<< b11001000000000100000
    1       <<< plot style sheet name assigned to this viewport

    281     <<< render mode (... too many options)
    0       <<< 0 = 2D optimized (classic 2D)
    71      <<< UCS per viewport flag
    1       <<< 1 = This viewport stores its own UCS which will become the
    ...     current UCS whenever the viewport is activated
    74      <<< Display UCS icon at UCS origin flag
    0       <<< this field is currently being ignored and the icon always
    ...     represents the viewport UCS
    110     <<< UCS origin (3D point)
    0.0     <<<     x value
    120     <<<     group code for y value
    0.0     <<<     y value
    130     <<<     group code for z value
    0.0     <<<     z value
    111     <<< UCS X-axis (3D vector)
    1.0     <<<     x value
    121     <<<     group code for y value
    0.0     <<<     y value
    131     <<<     group code for z value
    0.0     <<<     z value
    112     <<< UCS Y-axis (3D vector)
    0.0     <<<     x value
    122     <<<     group code for y value
    1.0     <<<     y value
    132     <<<     group code for z value
    0.0     <<<     z value
    79      <<< Orthographic type of UCS (... too many options)
    0       <<< 0 = UCS is not orthographic
    146     <<< elevation
    0.0
    170     <<< shade plot mode (0/1/2/3 for as displayed/wireframe/hidden/rendered)
    0       <<< as displayed
    61      <<< frequency of major grid lines compared to minor grid lines
    5       <<< major grid subdivided by 5
    348     <<< visual style ID/handle (optional)
    9F
    292     <<< default lighting flag, on when no user lights are specified.
    1
    282     <<< Default lighting type (0/1 = one distant light/two distant lights)
    1       <<< one distant light
    141     <<< view brightness
    0.0
    142     <<< view contrast
    0.0
    63      <<< ambient light color (ACI), write only if not black color
    250
    421     <<< ambient light color (RGB), write only if not black color
    3355443