Table of Contents

Class CadXrefManager

Namespace
OpenCAD2D
Assembly
OpenCAD2D.Core.dll

The external references and images of a document as the presenter shows them: each file found where AutoCAD looks for it, an external reference read once and drawn as the content of its block, and what was unloaded. Nothing it reads is written into the drawing but by -XREF Bind (BindXref(DxfBlockTableRecord, DxfDatabase, bool)): an external reference is shown, and saving writes its block and INSERTs alone, as AutoCAD writes them.

public sealed class CadXrefManager : IDisposable
Inheritance
CadXrefManager
Implements
Inherited Members

Remarks

A file is looked for as AutoCAD looks: the path the drawing saved, from the folder of the drawing that names it where the path is not full; then the file's name in that folder; then in the folder of the document's drawing; then in each of the document's SupportFolders. The reference ..\xref\grid.dxf of a drawing in D:\Plans\Workshop A is found at D:\Plans\xref\grid.dxf, and where that is gone, at D:\Plans\Workshop A\grid.dxf.

An external reference read keeps the time and size its file had, so that one changed on disk since stands as NeedsReloading until Reload reads it again. Unloading is the presenter's own and is not saved: no group of a DXF file says an external reference is unloaded.

Properties

WatchFiles

Gets or sets whether the folders of the files read are watched, so that FilesChanged is raised; off until set, as in a test.

Methods

Dispose()

Stops watching every folder.

GetDependentBlocks()

Gets the blocks the external references that are loaded bring into the drawing, as AutoCAD lists them in its block table while they are: grid|TAG for the block TAG of the drawing grid, each a copy with its objects, in the order of their names. A reference unloaded, not found or not read brings none; AutoCAD writes none of them to a DXF or a DWG, and the drawing's own BlockTable holds none (IsDependent is true of each). They are not to be inserted or changed: changing a copy changes nothing.

GetReferences()

Gets the external references of the drawing, then its images, each in ordinal order of its name, letters of either case alike first, with where it stands: an external reference no INSERT places is Unreferenced, one whose file is not found Not Found, and so on. An external reference not yet read is read here. Each one the drawing places is followed by the references its drawing attaches, nested, as the palette's tree shows them (Depth, ParentName), each in the order of its name; a nested overlay is not, as AutoCAD shows none. A nested reference whose parent is unloaded, not found or unresolved is Orphaned. The record AutoCAD keeps in the drawing of a nested reference, which no INSERT of the drawing places, is listed under its parent alone, not as an Unreferenced reference of its own.

IsUnloaded(string)

Gets whether an external reference of a name is unloaded.

Locate(string)

Finds the file a saved path names, as AutoCAD looks for it from the document's drawing (see the remarks of the class).

PathFor(string, CadPathType, string)

Gets the path to write for a file, as AutoCAD's Path type writes it: Full the full path; None the file's name; Relative the way from the drawing's folder, .\grid.dxf beside it and ..\xref\grid.dxf up one, the full path where the drawing has no folder yet (it is not saved) or the file is on another drive.

PathTypeOf(string)

Gets how a saved path is written: Full where it is rooted, None for a file's name alone, Relative otherwise.

Events

FilesChanged

Raised when a file an external reference was read from, or an image shows, changes on disk, while WatchFiles is on; raised on a thread of the watcher, not the window's.