Table of Contents

CadXrefManager

from OpenCAD2D import CadXrefManager

class CadXrefManager(System.Object) ยท CadXrefManager in the .NET reference

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 (DxfDatabase.BindXref): an external reference is shown, and saving writes its block and INSERTs alone, as AutoCAD writes them.

Properties and fields

WatchFiles

.NET

@property
def WatchFiles(self) -> bool
@WatchFiles.setter
def WatchFiles(self, value: bool) -> None

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

Events

FilesChanged

.NET

@property
def FilesChanged(self) -> System.EventHandler[System.EventArgs]
@FilesChanged.setter
def FilesChanged(self, value: System.EventHandler[System.EventArgs]) -> None

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

Methods

Dispose

.NET

def Dispose(self) -> None

Stops watching every folder.

GetDependentBlocks

.NET

def GetDependentBlocks(self) -> System.Collections.Generic.IReadOnlyList[DxfBlockTableRecord]

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 DxfDatabase.BlockTable holds none (DxfSymbolTableRecord.IsDependent is true of each). They are not to be inserted or changed: changing a copy changes nothing.

GetReferences

.NET

def GetReferences(self) -> System.Collections.Generic.IReadOnlyList[CadExternalReference]

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 (CadExternalReference.Depth, CadExternalReference.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

.NET

def IsUnloaded(self, name: str) -> bool

Gets whether an external reference of a name is unloaded.

Locate

.NET

def Locate(self, savedPath: str) -> str

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

PathFor

.NET

@staticmethod
def PathFor(fullPath: str, type: CadPathType, drawingFolder: str) -> str

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

.NET

@staticmethod
def PathTypeOf(savedPath: str) -> CadPathType

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

Operators and Python protocols

__enter__

def __enter__(self) -> Self

__exit__

def __exit__(self, *args: object) -> None