Table of Contents

Class CadDataLinks

Namespace
OpenCAD2D
Assembly
OpenCAD2D.Core.dll

The data links of a drawing, as AutoCAD 2021's DATALINK and DATALINKUPDATE and the table's data link menus work them: a link to a spreadsheet (an .xlsx workbook or a .csv file) made, changed, renamed and deleted, a table's cells linked to it, filled from its source and written back to it. A link is a DATALINK object of the drawing's ACAD_DATALINK dictionary, written as AutoCAD 2021 writes the link of its own Excel adapter (AcExcel): its adapter, tooltip and connection string, its options and update options, when it was last updated, the tables it fills and its custom data (the update options, the connection string and the source file's date), so that AutoCAD opens the drawing and reads the link as its own. A drawing before AutoCAD 2007 (AC1021) has no data links.

public static class CadDataLinks
Inheritance
CadDataLinks
Inherited Members

Fields

AllowSourceUpdate

The flag of AutoCAD's UpdateOption that lets the link write the table back to its source.

ExtractionAdapter

The data adapter of a data extraction's link, as AutoCAD names it.

SkipFormat

The flag of AutoCAD's UpdateOption that leaves the workbook's formatting out of the table.

Methods

CanHold(CadDocument)

Whether the drawing can hold data links: a drawing of AutoCAD 2007 (AC1021) or later with a dictionary of objects.

Create(CadDocument, CadDataLinkSettings)

Makes a data link, as the New Excel Data Link dialog does: one undo step. The name has to be new ("Data link name in use."), the source has to read, and the drawing has to be of AutoCAD 2007 or later.

Delete(CadDocument, string)

Deletes a data link, one undo step. A link that fills a table is in use and is refused, "The data link is being used and cannot be deleted."; detach it from the table first.

Detach(CadDocument, string, int, int)

Takes the data link off a table's cells, as Detach Data Link does: the cells keep what they hold and are no longer linked, one undo step. The link stays in the drawing, in the Data Link Manager.

Edit(CadDocument, string, CadDataLinkSettings)

Changes a data link, as Modify Excel Link does: its file, cells and options written anew, one undo step. The tables it fills are not changed until the link is updated.

Find(CadDocument, string)

Finds a link by its name, letters of either case alike.

FolderOf(CadDocument)

The folder of the drawing's file; null for a drawing not saved.

LinkCells(CadDocument, string, int, int, string)

Links a table's cells to a data link, as Link Cell does and as a table made from a data link is: the data read from the source and put into the table from the cell given, rows and columns added where the table is too small to hold it, the cells linked, one undo step. A table of a drawing before AutoCAD 2007, or whose cells are linked already, is refused.

List(CadDocument)

The data links of the drawing, by name.

Preview(CadDocument, CadDataLinkSettings)

Reads what a data link's settings link, for the dialog's preview and for the checks of Create(CadDocument, CadDataLinkSettings).

RelativePath(string, string)

The path from a folder to a file, ..\data\parts.xlsx; the file's full path where it is on another drive.

Rename(CadDocument, string, string)

Renames a data link, one undo step.

Update(CadDocument, IEnumerable<DxfDataLink>)

Updates data links from their sources, as DATALINKUPDATE's Update data link does: each link's source read, and the cells of each table it fills made what the source holds, rows and columns added or taken out to its size, the link's time and status written; one undo step. A link whose source cannot be read is counted as failed with its message and its tables left as they were.

Write(CadDocument, IEnumerable<DxfDataLink>)

Writes data links to their sources, as DATALINKUPDATE's Write data link does: the cells of each table a link fills put back into the workbook or the CSV file, whose other cells stay as they are. A link that does not allow it (its update options lack AllowSourceUpdate) is counted apart; a source that cannot be written is failed. The status of each link is written, one undo step.