Table of Contents

Class CadTemplate

Namespace
OpenCAD2D
Assembly
OpenCAD2D.Core.dll

The drawing NEW starts from: the presenter's own metric template, made in code with the settings of AutoCAD's acadiso.dwt (not its file). A drawing of R2013 in millimetres, its linear units decimal to four places and its angles decimal degrees to none, its limits an A3 sheet of 420 by 297, its text 2.5 high, its points dots, its Layout1 an A3 sheet in millimetres (UseMillimetreSheet(DxfDatabase)), and its dimensions drawn in ISO-25: arrowheads and text 2.5, the text above the line, two decimal places and a decimal comma.

public static class CadTemplate
Inheritance
CadTemplate
Inherited Members

Remarks

Every variable the template sets is written into the header, those the library would read the same where the header gives none among them, so that AutoCAD, which reads a variable the header leaves out as its own imperial drawing has it (MEASUREMENT 0, DIMSTYLE Standard, DIMASZ 0.18), opens the drawing as metric too.

The tables are layer 0, the linetypes ByBlock, ByLayer and Continuous, the text styles Standard (arial.ttf, as acadiso.dwt of AutoCAD 2021 has it) and Annotative (arial.ttf too), and the dimension styles Standard and ISO-25. AutoCAD adds Defpoints with the first dimension, and the multileader and table styles Standard when it opens the drawing; the library reads those styles but does not write them, so MLEADER has none to draw in until a drawing of AutoCAD's gives it one.

Fields

DimensionStyle

The name of the dimension style the template makes current.

Extensions

The file types a template is chosen among, as the Select Template dialog lists them.

SampleDescription

The description the sample template carries in its template section, the text Select Template shows under its name.

SampleFileName

The file name of the sample template that ships in the DrawingTemplates folder, written from CreateSample().

Methods

CreateImperial()

Makes a new drawing of the presenter's own imperial template, as AutoCAD's "Open with no Template - Imperial" starts one (the settings of acad.dwt, not its file): R2013 in inches, MEASUREMENT 0, its limits a sheet of 12 by 9, its text 0.2 high, and its dimensions drawn in Standard, arrowheads and text 0.18, four decimal places and a decimal point. The layer 0, the linetypes, the text styles Standard and Annotative are those of CreateMetric().

CreateMetric()

Makes a new drawing of the metric template: R2013 (AC1027), every setting of CadTemplate in its header and tables, nothing drawn.

CreateSample()

Makes the drawing of the sample template OpenCAD2D-mm.dwt, for a detail drawn at 1:1 in millimetres and printed on an A3 sheet: R2013, MEASUREMENT 1, INSUNITS 4 (millimetres), distances to two decimal places, limits of 42 000 by 29 700 (an A3 sheet at 1:100), LTSCALE and PSLTSCALE 1 (the dashes of the presenter's own linetypes are millimetres: CENTER has a dash of 31.75), and nothing drawn.

DescriptionOf(string)

Reads the description of a template, the text AutoCAD's Template Options writes into a DWG's template section. A file that is no DWG (a DXF), one with no description, and one that cannot be read have none.

Find(string, string)

Finds the file of a template named as typed: as typed, else in the template folder, else, for a name with no folder, the first of that name in the folder's subfolders; a name with no extension is given .dwt, as AutoCAD does.

FindIn(string)

Lists the templates of a folder and its subfolders: the .dwt, .dwg and .dxf files, in the order of the walk (OpenCAD2D.CadSupportWalk): the folder's own files by name (letters of either case the same, then as written) and then by extension, then the files of its subfolders in the same way, each subfolder after the folder it is in. Of two files of one name (sheet.dwt in the folder and in a subfolder) the first is listed, so the one at the top wins; empty where the folder is not there.

UseMillimetreSheet(DxfDatabase)

Sets up the layouts of a drawing as AutoCAD's acadiso.dwt has Layout1: a sheet of ISO A3 on its side, 420 by 297 millimetres with margins of 5 (Default), the paper in millimetres and the layout as the plot area. The library's new drawing leaves a layout with the paper in inches and no sheet (0 by 0), which reads as 25.4 millimetres to the unit and has nothing to plot on. Model space and the names of the layouts are left alone; so is a drawing read from a file, which is not given to this method.