--- jupyter: description: 'Title blocks and files in planex2d drawings: a sheet''s frame, the default title block and one from a DXF template, and the sheet written as SVG, as PDF at true scale and as DXF with real dimension entities.' --- # Title blocks and files A sheet for the workshop carries a frame and a title block. `px.Sheet(..., frame=True)` draws the frame: the border, the filing margin on the left, the centering marks and the grid reference zones. `sheet.Title(...)` adds a title block in the lower right corner and fills in its fields. A sheet is written in three formats: SVG, PDF at true scale, and DXF with real dimension entities. ```python import planex as px ``` ```python nbsphinx="hidden" plate = px.Sketch(auto_constraint=True) plate.RectangleC(120, 80, id="plate") plate.Constrain("plate.center", "origin", px.Coincident) plate.Constrain("plate.Line.1", px.Horizontal) plate.Constrain("plate.Line.1", px.Distance, 120, id="length") plate.Constrain("plate.Line.2", px.Distance, 80, id="width") plate.Fillet(["plate.Line.1.start", "plate.Line.2.start", "plate.Line.3.start", "plate.Line.4.start"], 8, id=["corner_1", "corner_2", "corner_3", "corner_4"]) for k in (2, 3, 4): plate.Remove(f"corner_{k}.r") plate.Constrain(f"corner_{k}", "corner_1", px.Equal) plate.Circle(20, id="bore") plate.Constrain("bore.center", "origin", px.Coincident) plate.Constrain("bore", px.Diameter, 40, id="bore_d") plate.Circle(30, id="bolt_circle", construction=True) plate.Constrain("bolt_circle", "bore", px.Concentric) plate.Constrain("bolt_circle", px.Diameter, 60, id="pitch") plate.Circle(4.5, center=(30, 1), id="hole") plate.Constrain("hole.center", "bolt_circle", px.Coincident) plate.Constrain("hole.center", "H", px.Coincident) plate.Constrain("hole", px.Diameter, 9, id="hole_d") plate.CircularPattern(["hole"], "origin", 4, id="holes") side = px.Sketch(px.XZ, auto_constraint=True) side.Move((-60, 0), px.Fix).Rectangle(120, 10, id="side") side.Constrain("side.Line.1", px.Horizontal) side.Constrain("side.Line.2", px.Distance, 10, id="thickness") front = px.Drawing(side, unit=px.mm) for x in (-34.5, -25.5, -20, -4.5, 4.5, 20, 25.5, 34.5): front.Line([(x, 0), (x, 10)], hidden=True) top = px.Drawing(plate, unit=px.mm).Center("bolt_circle", pitch=True) ``` ## The title block The default title block has these fields: the owner, the title and subtitle, the drawing number and revision, the date, the sheet, the scale, the size, the document's type and status, the department, a reference, the author and the approver. planex2d fills the fields the call leaves out where it can, which are the scale, the sheet's size, today's date and the sheet number. A keyword that is no field raises and names the fields there are: ```python sheet = px.Sheet(front, top, frame=True) sheet.Title(title="Bearing plate", number="BP-120", author="A. Engineer", status="Released") sheet ``` ## A company's title block A company's title block can be a DXF file whose attribute definitions are its fields. `sheet.Title("company.dxf", ...)` fills each field by its tag, in upper or lower case alike. ## Files `WriteSVG` and `WritePDF` write the sheet at true scale; the PDF is one page the size of the sheet, with the lettering embedded, and prints 1:1 at 100 %. `WriteDXF` writes the views at true size in millimeters, with dimension entities that a CAD program shows as dimensions and can edit, and the title block as a block with its attributes filled in. Read back with ezdxf, the DXF holds one dimension entity per dimension of the two views, 7 for the six of the top view and the thickness in the front view: ```python sheet.WriteSVG("bearing_plate.svg") sheet.WritePDF("bearing_plate.pdf") sheet.WriteDXF("bearing_plate.dxf") import ezdxf doc = ezdxf.readfile("bearing_plate.dxf") print(len(doc.modelspace().query("DIMENSION")), "dimension entities") ``` The sheet as files: [bearing_plate.pdf](bearing_plate.pdf), [bearing_plate.svg](bearing_plate.svg), [bearing_plate.dxf](bearing_plate.dxf)