CadTableEditor
from OpenCAD2D import CadTableEditor
class CadTableEditor(System.Object) ยท CadTableEditor in the .NET reference
Cut, Copy, Paste, Match Cell, Locking, Data Format, and Insert Block, Field and Formula of the cells of a table, as the Table Cell tab and the right-click menu of AutoCAD 2021 make them; each edit one undo step, "TABLEDIT". A cell locked (DxfCellState) in its content refuses to be typed into, emptied, cut, pasted over or given a block, field or formula; one locked in its format refuses its alignment, fill, borders, data format and paste.
The cell styles of the Table Cell tab: Title, Header and Data and those a user makes (Create New Cell Style, Manage Cell Styles), and the cell style a cell takes. A user's cell style lives in the table style's CELLSTYLEMAP; a cell takes one as AutoCAD does, the style's look written into the cell as its own overrides and its id into the cell's TABLECONTENT.
The edits of a table's cells, as AutoCAD's Table Cell tab and the right-click menu of a cell make them: the text of a cell, rows and columns put in and taken out, cells merged and unmerged, and the alignment, fill and borders of cells. Each is one undo step through CadDocument.ApplyEdit, asked of the gate as a change of the table's properties, and draws the table anew in its block (DxfTable.RecomputeTableBlock).
The Insert group of the Table Cell tab (a block, a field, a formula) and Data Format, and the working out of the formulas and fields of a table's cells. The formulas are those of CadTableFormula, written as AutoCAD's SetFormula writes them (a field of the evaluator AcExpr) and worked out again after every edit of the table.
Methods
CellName
@staticmethod
def CellName(row: int, column: int) -> str
Gets the name AutoCAD gives a cell: its column's letters and its row's number from 1, as C3 for the row 2 and the column 2.
CellNear
@staticmethod
def CellNear(table: DxfTable, point: GeoPoint2) -> tuple[bool, int, int]
Gets the cell of a table nearest a point of the plan: the cell it falls in, or where it falls outside the table, the cell of the last row or column on that side, as a drag across cells holds the range at the table's edge.
CellStyleNames
@staticmethod
def CellStyleNames(table: DxfTable) -> System.Collections.Generic.IReadOnlyList[str]
The names of the cell styles the table style of a table holds, Title, Header and Data first; the three where the table names no style.
CellStyleOf
@staticmethod
def CellStyleOf(table: DxfTable, row: int, column: int) -> str
Gets the name of the cell style a cell takes: that its TABLECONTENT names (Title, Header, Data or a user's), else that of its row (the title, the header or the data), as the Cell Styles box of the tab shows it.
ClearContents
@staticmethod
def ClearContents(document: CadDocument, handle: str, range: DxfCellRange) -> CadEditResult
Empties the cells of a range, as Delete and Delete All Contents do: their text or block taken, their look kept.
ColumnName
@staticmethod
def ColumnName(column: int) -> str
Gets the letters AutoCAD gives a column: A to Z, then AA, AB and on.
Copy
@staticmethod
def Copy(table: DxfTable, range: DxfCellRange) -> CadTableCellClip
Takes the cells of a range as a snapshot, with their contents and looks: what Copy puts on the clipboard.
Corners
@staticmethod
def Corners(table: DxfTable, range: DxfCellRange) -> System.Array[GeoPoint2]
Gets the corners of a range of cells, the top left first, then about it, in the plan.
CreateCellStyle
@staticmethod
def CreateCellStyle(document: CadDocument, tableStyleName: str, name: str, startWith: str) -> CadEditResult
Makes a cell style of a table style, as Create New Cell Style does: of the name given, starting from the look of one of the style's. One undo step.
Cut
@staticmethod
def Cut(document: CadDocument, handle: str, range: DxfCellRange) -> tuple[CadEditResult, CadTableCellClip]
Cuts the cells of a range, as Cut does: they are copied, then their contents taken out as Delete takes them, their looks and merges kept, in one undo step. Refused where a cell is locked in its content.
DeleteCellStyle
@staticmethod
def DeleteCellStyle(document: CadDocument, tableStyleName: str, name: str) -> CadEditResult
Takes a cell style a user made out of a table style, as Delete does in Manage Cell Styles; Title, Header and Data stay. One undo step.
DeleteColumns
@staticmethod
def DeleteColumns(document: CadDocument, handle: str, column: int, count: int) -> CadEditResult
Takes out columns, as Delete Column(s) does; refused where no column would be left.
DeleteRows
@staticmethod
def DeleteRows(document: CadDocument, handle: str, row: int, count: int) -> CadEditResult
Takes out rows, as Delete Row(s) does; refused where no row would be left.
Fill
@staticmethod
def Fill(
document: CadDocument,
handle: str,
fillRange: DxfCellRange,
sourceRange: DxfCellRange,
options: DxfTableFillOptions,
) -> CadEditResult
Fills cells from others, as the autofill grip of a cell does: DxfTable.Fill in one undo step, "Autofill". A 1 in A3 filled down into A4 to A6 with DxfTableFillOptions.GenerateSeries and DxfTableFillOptions.CopyFormat, as Fill Series fills, gives 2, 3 and 4, as AutoCAD 2021 filled them.
Grown
@staticmethod
def Grown(table: DxfTable, range: DxfCellRange) -> DxfCellRange
Gives a range of cells grown to take in every block of merged cells it meets, as a selection of cells takes them.
InsertBlock
@staticmethod
def InsertBlock(
document: CadDocument,
handle: str,
row: int,
column: int,
blockName: str,
scale: float,
autoFit: bool,
rotation: float,
alignment: DxfCellAlignment | None,
) -> CadEditResult
Puts a block into a cell, as the Insert a Block in a Table Cell dialog does: the cell a block cell of the block, fitted to the cell (AutoFit) or at the scale given, turned, and its content aligned as given, one undo step. A block cell given another block keeps its scale and turn unless the dialog asks again.
InsertColumn
@staticmethod
def InsertColumn(document: CadDocument, handle: str, column: int, right: bool) -> CadEditResult
Puts in a column left or right of a column, of its look, as Insert Left and Insert Right do.
InsertField
@staticmethod
def InsertField(document: CadDocument, handle: str, row: int, column: int, fieldCode: str) -> CadEditResult
Puts a field into a cell, as Insert Field does with the Field dialog's code: the cell shows the words the field comes to, and keeps the field to evaluate again, one undo step.
InsertFormula
@staticmethod
def InsertFormula(document: CadDocument, handle: str, row: int, column: int, formula: str) -> CadEditResult
Puts a formula into a cell, as Insert Formula does: =Sum(A1:B3), =Average(C2:C9), =Count(A1:A5), a cell =B2 or an equation =A1*B1+2; the cell shows what the formula comes to, and every formula of the table is worked out again after each edit, one undo step. A formula that cannot be worked out (a cell of words in it, a division by nought) shows #####.
InsertRow
@staticmethod
def InsertRow(document: CadDocument, handle: str, row: int, below: bool) -> CadEditResult
Puts in a row above or below a row, of its look, as Insert Above and Insert Below do.
MatchCell
@staticmethod
def MatchCell(
document: CadDocument,
sourceHandle: str,
sourceRow: int,
sourceColumn: int,
handle: str,
range: DxfCellRange,
) -> CadEditResult
Matches cells to another, as Match Cell does: the look of the source cell (its alignment, text height, style and colour, fill, borders and data format) given each cell of the range, their contents kept; one undo step.
Merge
@staticmethod
def Merge(document: CadDocument, handle: str, range: DxfCellRange) -> CadEditResult
Merges the cells of a range into one, as Merge All does: its text that of its top left cell.
MinimumColumnWidth
@staticmethod
def MinimumColumnWidth(table: DxfTable, column: int) -> float
Gets the least width a column of a table may be dragged to, as AutoCAD 2021's MinimumColumnWidth: its two horizontal margins and the tallest text height of its cells, or where a block cell starts in it that is not fitted to its cell, the width its block's extents fill at the cell's scale and turn with the two margins, if that is more. AutoCAD's Standard of margins 1.5 and a title of 6 gives 9, and a block 30 wide 33 (63 at scale 2, 31.28427 turned 45 degrees); a block merged across columns asks the column it starts in alone. The words of an attribute definition in the block are in its extents where the drawing's fonts find them (DxfDatabase.FontSearchPath).
Paste
@staticmethod
def Paste(document: CadDocument, handle: str, range: DxfCellRange, clip: CadTableCellClip) -> CadEditResult
Pastes cells at the top left cell of a range, as Paste does: each cell given the content and the look of the one copied (a number with its format, words as they were typed, a block with its scale and attribute values, a field, a formula with its references moved by the rows and columns it moved), the merges within the cells copied made again and those the paste meets taken out. A range of whole multiples of the cells copied is filled with them side by side. What falls past the table's last row or column is left out. One undo step; refused where a cell pasted over is locked.
RemoveOverrides
@staticmethod
def RemoveOverrides(document: CadDocument, handle: str, range: DxfCellRange) -> CadEditResult
Takes away what the cells of a range hold of their own over the table style, as Remove All Property Overrides does (DxfTable.RemoveAllOverrides): their text, values and merges kept.
RenameCellStyle
@staticmethod
def RenameCellStyle(document: CadDocument, tableStyleName: str, name: str, newName: str) -> CadEditResult
Renames a cell style a user made, as Rename does in Manage Cell Styles. One undo step.
SetAlignment
@staticmethod
def SetAlignment(
document: CadDocument,
handle: str,
range: DxfCellRange,
alignment: DxfCellAlignment,
) -> CadEditResult
Sets where the content of the cells of a range stands, as the alignment of Cell Styles does.
SetBackground
@staticmethod
def SetBackground(document: CadDocument, handle: str, range: DxfCellRange, color: DxfColor) -> CadEditResult
Fills the cells of a range with a colour, or leaves them unfilled, as the fill of Cell Styles does.
SetBorders
@staticmethod
def SetBorders(
document: CadDocument,
handle: str,
range: DxfCellRange,
lines: DxfGridLineType,
visible: bool,
) -> CadEditResult
Draws or hides lines of a range of cells, as the border buttons do: All borders, Outside borders, Inside borders, the bottom, left, top or right, or none (DxfGridLineType.AllGridLines hidden).
SetCellBorders
@staticmethod
def SetCellBorders(
document: CadDocument,
handle: str,
range: DxfCellRange,
lines: DxfGridLineType,
visible: bool,
weight: DxfLineWeight,
color: DxfColor,
) -> CadEditResult
Gives lines of a range of cells properties, as OK of the Cell Border Properties dialog does: the lines (All, Outside, Inside, Bottom, Left, Top or Right, or all of them hidden by No Border) drawn or not, and, where they are drawn, their lineweight and colour; one undo step. A range of one row or column has no lines inside it of that way.
SetCellStyle
@staticmethod
def SetCellStyle(document: CadDocument, handle: str, range: DxfCellRange, styleName: str) -> CadEditResult
Gives the cells of a range a cell style, as choosing one in the Cell Styles box does: its look (alignment, text height, text style and colour, fill and the four borders) written as the cells' own overrides over what they held, their contents kept, and its id written into their TABLECONTENT; null is By Row/Column: the cells name no style and keep what they hold. One undo step.
SetColumnWidths
@staticmethod
def SetColumnWidths(
document: CadDocument,
handle: str,
column: int,
widths: System.Collections.Generic.IReadOnlyList[float],
) -> CadEditResult
Sets the widths of columns, from one on, in one undo step, "Column Width", as a drag of a column's line does; the rows then grow to hold text that wraps anew. A width below CadTableEditor.MinimumColumnWidth is taken as that, as AutoCAD 2021 holds a column there: columns of 30 and 22.5 given 38 and 14.5 keep the table's width, and one given 1 in AutoCAD's Standard is 9 wide.
SetDataFormat
@staticmethod
def SetDataFormat(
document: CadDocument,
handle: str,
range: DxfCellRange,
kind: DxfDataType,
unit: DxfUnitType,
format: str,
) -> CadEditResult
Gives the cells of a range a kind of data and a format, as the Data Format dialog does: the kind (a number, a whole number, words) and its unit (a length, an angle, money, a percentage), then the format, as %lu2%pr2%ps[$,]%th44 for money of two places with a dollar sign and commas; the values kept, shown anew. One undo step.
SetLocking
@staticmethod
def SetLocking(document: CadDocument, handle: str, range: DxfCellRange, state: DxfCellState) -> CadEditResult
Locks or unlocks the cells of a range, as the Cell Locking menu does: Unlocked (DxfCellState.None), Content Locked, Format Locked, or Content and Format Locked, one undo step. The flag of a linked cell is kept.
SetRowHeights
@staticmethod
def SetRowHeights(
document: CadDocument,
handle: str,
row: int,
heights: System.Collections.Generic.IReadOnlyList[float],
) -> CadEditResult
Sets the heights of rows, from one on, in one undo step, "Row Height", as a drag of a row's line does; a row is never lower than its text needs, grown back to it as the table is drawn anew.
SetText
@staticmethod
def SetText(document: CadDocument, handle: str, row: int, column: int, text: str) -> CadEditResult
Writes the text of a cell, as typing in it does; the same text changes nothing. A number typed, spaces round it left out, is kept as a number unless the cell is made to hold text, as AutoCAD 2021 reads a text it parses into a value (ConvertTextToValue): 1 is the whole number 1 and 007 the whole number 7, so that the autofill grip dragged from it counts 2, 3, 4; 1.5 a number shown in the drawing's units, 1.5000 at LUPREC 4, 1e3 one shown 1.0000E+03 and 1/2 one shown 1/2, each standing top right where the cell has no alignment of its own; 1,5 the point (1, 5, 0) shown 1.0000, 5.0000, 0.0000; and a number typed in a cell of a number keeps the cell's kind and format, 12 over 1.25 shown 12.0000. A date or a time, in the order of the culture of the machine, is a date as AutoCAD 2021 reads it: 1/2/2020 or 12:30 of a cell of no kind, shown 1/2/2020 or 12:30:00 PM (the formats %x, %X and %c for a date, a time and both), and any other words over a cell of a date are refused. b1 and 12mm stay text.
StyleOf
@staticmethod
def StyleOf(table: DxfTable) -> DxfTableStyle
Gets the table style a table is written in; null where the table names none.
TryCellAt
@staticmethod
def TryCellAt(space: CadSpace, point: GeoPoint2) -> tuple[bool, str, int, int]
Gets the table of a space a point of the plan falls in, and its cell, the table appended last first; false where it falls in none.
TryHit
@staticmethod
def TryHit(table: DxfTable, point: GeoPoint2) -> tuple[bool, int, int]
Gets the cell of a table a point of the plan falls in, seen from above; false where it falls in none.
Unmerge
@staticmethod
def Unmerge(document: CadDocument, handle: str, range: DxfCellRange) -> CadEditResult
Unmerges every block of merged cells a range meets, as Unmerge Cells does.