Method AddToLayoutDictionary
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
AddToLayoutDictionary(DxfDatabase, DxfBlockTableRecord)
Adds a layout made in code to a drawing, as AutoCAD's AddToLayoutDictionary: a LAYOUT at the end of the OBJECTS
section, named in the layout dictionary (ACAD_LAYOUT) by its LayoutName, on the tab after the last, with
the plot settings of a sheet of A3 on its side and no plotter; and the block that holds its entities, whose
BLOCK_RECORD names the layout (group 340), made where none is given. The layout has no viewport until
Initialize() gives it one.
public void AddToLayoutDictionary(DxfDatabase toWhichDatabase, DxfBlockTableRecord blockTableRecord)
Parameters
toWhichDatabaseDxfDatabaseThe drawing, of R2000 or later.
blockTableRecordDxfBlockTableRecordThe block of the layout: one of the drawing's named
*Paper_Spaceand a number, as AutoCAD names those of its layouts, that no layout has, its BLOCK_RECORD naming none (340 of 0, or no 340); null to have one made.
Remarks
A drawing ezdxf made with Model, Layout1 and Sheet A on tab 3, its block *Paper_Space0, is given
new DxfLayout { LayoutName = "Plan 1-50" } on tab 4 with the block *Paper_Space1, the first of
*Paper_Space0, *Paper_Space1 and on the drawing has not, as AutoCAD and ezdxf name it.
The plot settings are ezdxf's for a new layout, named as AutoCAD names no plotter and its sheet of ISO A3: no page
setup, the device none_device, the sheet ISO_A3_(420.00_x_297.00_MM) 420 by 297 in millimetres,
margins 7.5 at the sides and 20 above and below, plotted as a layout at 1:1 (flags 688: viewports first,
lineweights, plot styles, the standard scale), shaded as displayed at the normal level of 300 dots an inch. The
limits are the sheet about the corner of its plotted area, (-7.5, -20) to (412.5, 277), its extents empty, its user
coordinate system the world's, and its flags 1 (PSLTSCALE), as ezdxf's layouts have them.
Another sheet is set once the layout is added, before Initialize() sizes its viewport 1 by the limits:
plan.CanonicalMediaName = "ISO_A1_(841.00_x_594.00_MM)" for A1 on its side.
Each layout added costs a little more the more the drawing has, its dictionary and block table written anew: 200 layouts added and initialized in one drawing take 0.14 to 0.25 s once the code is compiled, and 0.35 to 0.56 s as the first work of a process; AutoCAD allows 255.
Exceptions
- ArgumentNullException
Thrown when the drawing is null.
- ArgumentException
Thrown when the drawing has a layout of the name already, letters of either case the same, or the block given is not one of the drawing's named
*Paper_Spaceand a number, or is a layout's.- InvalidOperationException
Thrown when the layout is in a drawing already, or has no name, or the drawing has no layout dictionary, as one older than R2000 (AC1015) has none.