@hippe013 , now I retest the code again, and I found that even though the all the value in the command line result checks out ( like what you showed), but the actual table is not rendered correctly-- the value table column value still retains the old one, as per here.
Here's my code.
[CommandMethod(nameof(CmdStructureTableStyleColumnEdit))]
public void CmdStructureTableStyleColumnEdit()
{
Document aDoc = Application.DocumentManager.MdiActiveDocument;
Editor ed = aDoc.Editor;
Database db = aDoc.Database;
CivilDocument cvlDoc = CivilApplication.ActiveDocument;
StylesRoot styles = cvlDoc.Styles;
ObjectId styleId = styles.TableStyles.StructureTableStyles["Basic"];
using Transaction tr = db.TransactionManager.StartTransaction();
var style = tr.GetObject(styleId, OpenMode.ForWrite) as TableStyle;
ed.WriteMessage("\n" + $"Modifying Style: {style.Name}");
// Get the columnStyle and modify its header
var colmStyle = (StructureColumnStyle)style.ColumnStyles[0];
ed.WriteMessage("\n" + $"Current Column Header: {colmStyle.HeaderString}");
colmStyle.HeaderStringFormatted = "Structure Description";
ed.WriteMessage("\n" + $"New Column Header: {colmStyle.HeaderString}");
// Get the component data
StructureColumnComponents structColmComp = colmStyle.GetComponents();
StructureColumnComponentData structColmCompData = structColmComp[0];
ed.WriteMessage("\n" + $"Current Component Data (Name / Content): {structColmCompData.Name} | {structColmCompData.Content}");
// Set the new values of the component
structColmCompData.Name = "Structure Description";
structColmCompData.Content = "<[Description(CP)]>";
colmStyle.SetComponents(structColmComp);
// Print changes made to the component
ed.WriteMessage("\n" + $"New Component Data (Name / Content): {structColmCompData.Name} | {structColmCompData.Content}");
tr.Commit();
}
Note that I use the Basic style for the Structure Table.
You can use another drawing but I suspect the result would be the same.
To solve the problem, you need to "manually update" the column value in the UI by click on "Edit Table Style", select the related column, then click into it and click OK until you go to Text Component Editor, and then click OK ( no need to change anything). Then click apply. Only then the table rendering will be updated.
##########
Ngu Soon Hui##########
I'm the Benevolent Dictator for Life for
MiTS Software. Read more
here I also setup
Civil WHIZ in order to share what I learnt about Civil 3D