Like this (sorry for the delay). # IronPython import clr clr.AddReference('Manifold.Interop') from Manifold.Interop import ColumnType # enum # def Main(): log = Application.History.Log drw = Document.ComponentSet('Drawing') tbl = drw.OwnedTable cols = tbl.ColumnSet # add and adjust target columns as necessary for (col_name, col_type) in ( ('Red', ColumnType.ColumnTypeInt8U), ('Green', ColumnType.ColumnTypeInt8U), ('Blue', ColumnType.ColumnTypeInt8U) ): col_index = cols.ItemByName(col_name) if col_index >= 0: # named column exists: check type col = cols(col_index) if col.Type != int(col_type): log('Adjust type of column [' + col_name + ']\r\n', True) col.Type = col_type else: # create new column col = cols.NewColumn() col.Name = col_name col.Type = col_type log('Add new column [' + col_name + ']\r\n', True) cols.Add(col) # # populate RGB columns with formatting values for obj in drw.ObjectSet: rec = obj.Record colour = obj.BackColor rec._PutData('Red', colour.Red) rec._PutData('Green', colour.Green) rec._PutData('Blue', colour.Blue) # Main() To install IronPython check here. Attachments: Write background colour to table.py
|