util/object/table.lsp [src]
Table-handling functions
Some functions here have side effects such as modifying text in MLEADER callouts to match
the table. This is primarily fab-oriented but, with care, can be used for any table
operations.
(get-all-tables)
Returns a list of all tables
(get-table-by-title title)
Returns the table with matching TITLE
TITLE is matched against cell A1 of all tables in the database using wcmatch, so any
wildcards wcmatch accepts will work here.
Automatically calls table--fix
VARS:
(TITLE STR)
(get-table-cell)
Prompts user for a point and checks if it is inside in a table
If so, it returns a list of the form (table row column).
(material-table-p table)
Returns T if TABLE is a *Material table, i.e that its title ends-with "Material"
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(parse-table table)
Returns the data in TABLE as a list of data lists
Each list item corresponse to a row. The keys of the datalists correspond to the column
names. The names are converted to lowercase and spaces are replaced with underscores to
form the key names.
Rows whose first column is blank are not considered. The first row is the title row, with
the table title at 0,0. The second row is considered the header row and column names come
from this row.
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(table-add-data table datas)
Adds bulk data to the end of TABLE with regeneration suppressed
DATAS is a list of data lists representing row data.
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(DATAS LIST (VL-EVERY 'DATA-LIST-P DATAS))
(table-divide-qty table n)
Divides every quantity in TABLE by N
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(N INT)
(table-get-column-names table)
Returns the column names as a list of formatted strings
Strings are formatted by table--format-column-name
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(table-get-nrows table)
Returns the number of effective rows in TABLE
Effective rows includes the title, header, and body rows except for the weight summary row
in *Material tables.
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(table-get-title table)
Returns the contents of cell 0,0
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(table-insert-rows table nrows after)
Inserts NROWS rows in a fab drawing TABLE after row AFTER
If this is a generic fab table there are other generic fab tables below this one, move
them down to accomodate. If this is the Assembly* table, update the quantities in Material
and Hardware tables, if found.
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(NROWS INT)
(AFTER INT)
(table-multiply-qty table n)
Multiplies every quantity in TABLE by N
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(N INT)
(table-p obj)
Returns T if OBJ is a table
VARS:
(OBJ VLA-OBJECT)
(table-set-row table row data)
Sets a ROW in TABLE
ROW is a row index and DATA is a data list whose keys correspond to the table columns. If TABLE is a material table, attempts to set the weight formula.
To add data in bulk with formula regeneration disabled to improve performance, see
table-add-data
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(ROW INT (>= ROW 0))
(DATA nil (DATA-LIST-P DATA))
(table-trim-empty-rows table row)
Trims empty rows from TABLE, starting at ROW
Determines if row is empty using table--empty-first-column-p
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(ROW INT)
(--shift-tables names delta-y)
Move the tables named in NAMES vertically by DELTA-Y
VARS:
(NAMES (LIST nil) (VL-EVERY 'STRINGP NAMES))
(DELTA-Y nil (NUMBERP DELTA-Y))
(--shift-tables-maybe title delta-y)
If TITLE is one of the generic fab tables, call --shift-tables
(get-table-cell--bounding-box table row col)
Returns the bounding box for the cell as a list of the form (minpt maxpt)
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(ROW INT)
(COL INT)
Returns the weight formula for a material description
For qty, weight, and length columns, if they are required and a null value is present, set the column to a default value. For weight and length, the default is 0. For qty, the default is 1 (Misc Material) or the number of assemblies (Material).
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(ROW INT)
(mat-table--fix-summary-row table)
Change the last row to be a simple sum of weight column if necessary
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(mat-table--set-weight-column table row)
Does necessary formatting and sets the weight column
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(ROW INT)
(mat-table--update-marks table +- n row)
Update fab mark numbers in TABLE and callouts
+- should be one of the built-in functions + or -, indicating whether the mark numbers
should increase or decrease. N is the number of places the number should jump. ROW is the
first row in the material table containing mark numbers to change.
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(+- SUBR (MEMBER +- (LIST + -)))
(N INT)
(ROW INT)
(mat-table--update-total-weight table)
Updates the formula for each weight in TABLE to include any added rows
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE) (MATERIAL-TABLE-P TABLE))
(table--abbr-desc-column table)
If there is a "Description" column in TABLE, rewrites it as "Desc"
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(table--body-rows table)
Returns a list of body (not title or header) row indices in TABLE
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(table--cells table)
Returns a list of cells in TABLE as 2-item lists of the form (row col)
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(table--column-name->letter name)
Returns the letter designation of the column named NAME
Either 'col-names or 'table must be defined.
VARS:
(NAME STR)
Wrapper for vla-SetCellFormat
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(ROW INT)
(COL INT)
(table--empty-first-column-p table row)
Returns T if column 0 of ROW is empty
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(ROW INT)
Returns NAME as lowercase with spaces replaced by underscores
VARS:
(NAME STR)
(table--get-column-names-maybe table)
If the symbol 'col-names is defined, returns its value. Otherwise, calls table-get-column-names
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
Returns the index of the row containing the column headers
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(table--get-title-maybe table)
If the symbol TITLE is defined, returns its value. Otherwise, calls table-get-title
VARS:
(TABLE VLA-OBJECT (TABLE-P TABLE))
(table--pt-in-table-p pt table)
Returns T if PT is within TABLE's bounding box
VARS:
(PT LIST (POINT-P PT))
(TABLE VLA-OBJECT (TABLE-P TABLE))