Class CadSheetSetFile
A sheet set data file (.dst), AutoCAD 2021's own format, opened, changed and saved. The file is UTF-8 XML under a one-byte cipher; its XML tree is kept whole in memory and the model (SheetSet and what hangs from it) reads and writes through that tree, so every element and property this program does not know (the sheet selections, the transmittal setups, the callout block lists, the DWF options) is saved as it was read. A set made here opens in AutoCAD and one made in AutoCAD opens here.
public sealed class CadSheetSetFile
- Inheritance
-
CadSheetSetFile
- Inherited Members
Remarks
Every change is saved at once, as in AutoCAD: Change(Action<CadSheetSet>) applies an edit to the set, writes the file to
name.dst.tmp and replaces the file with it, and the FileRevision goes up by one. If the file's
time stamp or length has moved since it was read (another copy of the program, or AutoCAD, saved it), the set is
reloaded first and the edit applied to the fresh copy. An edit that throws saves nothing and leaves the tree as it was.
The parts of the model can be changed only inside Change(Action<CadSheetSet>); the objects handed out belong to the copy that
was loaded and are stale after a reload, so read them again from SheetSet.
New objects get an ID of a g and an upper-case GUID, from NewGuid() or, where a test
gives Open or Create a source of its own, a counter, so that the bytes of a set are the same on every run.
The order of the set is the order of the XML, and nothing here follows the order of a dictionary.
Properties
- DbFingerPrint
Gets the fingerprint of the database (
DbFingerPrint, agand a GUID), which AutoCAD keeps from the day the set was made.
- DbVersion
Gets the version of the format the file says it is (
DbVersion); "1.1" for a set made here, as AutoCAD 2021 writes a new one.
- FileRevision
Gets how many times the file has been saved (
FileRevision).
- Folder
Gets the folder of the .dst, which the relative form of every file reference in it is relative to.
- HasChangedOnDisk
Gets whether the file's time stamp or length is not what it was when it was read or last saved here. False where the file is gone.
- HoldsLock
Gets whether this copy holds the lock file of the set (OpenForEditing(string) wrote it and ReleaseLock() has not deleted it).
- IsReadOnly
Gets whether the set is read-only (ReadOnlyReason is not null): every Change(Action<CadSheetSet>) is refused.
- LockedBy
Gets the lock of another user that makes the set read-only; null where there is none, or the file was not opened with OpenForEditing(string).
- Path
Gets the full path of the .dst.
- ReadOnlyReason
Gets why the set cannot be changed, or null where it can: the file is read-only ("The sheet set data file is read-only."), another user holds its lock ("Locked for Edit by InuYasha on INUYASHA-MEV.") or the lock file could not be written. Asked again each time, so a file made read-only after it was opened shows.
- SheetSet
Gets the sheet set, the root of the model. It is new after every Change(Action<CadSheetSet>) that reloads.
Methods
- Change(Action<CadSheetSet>)
Changes the sheet set and saves it: reloads the file first where it has moved on disk, runs the edit on the (fresh) SheetSet, and where the edit changed anything writes the file at once and raises the FileRevision by one. An edit that throws, or a save that fails, leaves the file and the tree as they were and the exception goes on.
- CheckLayouts(string)
Checks the layouts of a drawing for the wizard's Choose Layouts page, before any set is there: as CheckLayouts(string) does for a set, without the check against its sheets.
- Create(string, string, string)
Makes an empty sheet set and saves it, as AutoCAD's New Sheet Set.dst is: no template (so a new sheet asks for one), new sheets going to the folder of the .dst, one default view category, PDF publish options asking for a name. DbVersion is "1.1" and FileRevision 1.
- CreateFromDrawings(string, string, string, IEnumerable<CadSheetImportSource>, CadSheetImportOptions)
Makes a sheet set of layouts of drawings that exist, as the wizard's second route does: an empty set, then the layouts of each source imported as sheets in the order given (with the set marks written into the drawings), into subsets made from the folders where the options say so. Nothing is left behind where an import is refused: the .dst is deleted again (drawings already marked keep a mark that names a set that is not there).
- CreateFromExample(string, string, string, string, bool)
Makes a sheet set from an example, as the wizard's first route does: the example's organisation and settings are kept (its subsets, nested as they are, its custom properties, sheet creation template and folder, publish options, view categories and the parts this program does not model) and its sheets are left out. Every part has an ID of its own, every file the example names is named again relative to the new .dst, a folder that was the example's own folder becomes the new one, and the file is saved with DbVersion "1.1" and FileRevision 1.
- Open(string)
Reads a sheet set data file.
- OpenForEditing(string)
Opens a sheet set data file as the Sheet Set Manager does to work in it (D21): the file is read, and the lock file beside it is looked at. A set whose file is read-only, or whose lock is another user's, opens read-only (IsReadOnly, LockedBy) and no lock file is written. Otherwise this user takes the lock: the .DBL file is written (CadSheetSetLock) and stays until ReleaseLock(). A folder the lock file cannot be written in makes the set read-only too.
- ReleaseLock()
Lets go of the lock the set was opened with (OpenForEditing(string)): the lock file is deleted. Does nothing where this copy holds none.
- ReloadIfChanged()
Reloads the file where its time stamp or length has moved since it was read or last saved here.