Table of Contents

Method SetAt

Namespace
GeometryHelper.Dxf
Assembly
GeometryHelper.dll

SetAt(string, DxfDBObject)

Adds an object under a name, as AutoCAD's SetAt: an object made in code written into the file as the dictionary's own, last among its entries, as AutoCAD writes it; where the name has an entry already, the object it named is erased, with what it owns, and the entry names the new one, as AutoCAD replaces it.

public void SetAt(string searchKey, DxfDBObject newValue)

Parameters

searchKey string

The name, letters of either case the same as an entry's.

newValue DxfDBObject

The object, made in code and in no file yet.

Remarks

A DxfDBDictionary, a DxfXrecord with its data and a DxfGroup with its description are added: db.GroupDictionary.SetAt("BEAMS", new DxfGroup("Beams of grid A", true)) adds the group BEAMS, empty until entities are appended to it. A group added under the name * is anonymous, as AutoCAD names one: it is given the first name *A1, *A2 and on the dictionary has not. A DxfTableStyle is written with every group AutoCAD writes of one: db.TableStyleDictionary.SetAt("GH_SCHEDULE", new DxfTableStyle()) adds a style of AutoCAD's Standard in millimetres. A DxfMLeaderStyle is written with every group AutoCAD 2021 holds of one, its class listed and counted in CLASSES: db.MLeaderStyleDictionary.SetAt("GH_NOTES", new DxfMLeaderStyle { TextHeight = 2.5, ArrowSize = 2.5 }) adds a style of words and arrows 2.5 high. A DxfPlotSettings is a named page setup: db.PlotSettingsDictionary.SetAt("A3 plan", new DxfPlotSettings()) adds one of an ISO A3 sheet and no plotter, named by its entry, with its class PLOTSETTINGS listed and counted in CLASSES; set it, or copy a layout's settings into it (CopyFrom(DxfPlotSettings)), once it is added.

The entries are found by name without reading the record again, and the new one is put into the record's bytes as they stand, so that an entry added costs only a copy of the record: 2 000 XRECORDs added one by one to one dictionary take 0.02 s, and 10 000 take 1.1 s.

Exceptions

ArgumentNullException

Thrown when the name or the object is null.

ArgumentException

Thrown when the name is empty or has a control character in it, or the object is in a file already or of a class the library does not add: a DxfLayout, whose place is the layout dictionary, or one of no class of its own; or it is a DxfRasterImageDef and the name has an entry, as AutoCAD 2021's SetAt erases the definition there and leaves the images that show it out of the file it writes: add it under the name SuggestName(DxfDBDictionary, string) gives.

InvalidOperationException

Thrown when this dictionary is in no file, or is erased.