Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Why don't CustomTable text styles affect their respective areas of the table?

Anonymous

Why don't CustomTable text styles affect their respective areas of the table?

Anonymous
Not applicable

Hi folks,

This code is meant to set the styles for a CustomTable in an Inventor drawing.  There are 3 sections in the following which format the title text style, column header text style, and data text style.  Ideally, those would affect the title text, header text, and data text, respectively.

Unfortunately, whichever one comes last in the order of the code is the only one which ends up being applied as the style for all those types of text.  And it also gets applied to other existing tables in the drawing, such as the title block, which is not desired.

 

    // create the custom table
    CustomTable customTable = activeSheet.CustomTables.Add("Custom Table",
        InvApp.TransientGeometry.CreatePoint2d(60, 30), numCols, numRows, titles, contents, columnWidths);

    // title text style
    customTable.TitleTextStyle.Font = "Italic";
    Inventor.Color titleTextColor = InvApp.TransientObjects.CreateColor(255, 0, 0);
    customTable.TitleTextStyle.Color = titleTextColor;
    customTable.HeadingPlacement = HeadingPlacementEnum.kHeadingAtTop; // (places overall title, not header titles)
    customTable.ShowTitle = true;

    // column header text style
    customTable.ColumnHeaderTextStyle.Font = "Courier New";
    Inventor.Color columnHeaderTextColor = InvApp.TransientObjects.CreateColor(0, 0, 0);
    customTable.ColumnHeaderTextStyle.Color = columnHeaderTextColor;

    // data text style
    customTable.DataTextStyle.Font = "Arial";
    customTable.DataTextStyle.Italic = false;
    Inventor.Color dataTextColor = InvApp.TransientObjects.CreateColor(150, 50, 150);
    customTable.DataTextStyle.Color = dataTextColor;

    // grid line weights
    customTable.Style.InsideLineWeight = 0.05;
    customTable.Style.OutsideLineWeight = 0.05;

(This is C# code for an Inventor 2018 add-in.)

Using a table format object with OverrideFormat does not help matters.

1.) Why do the separate text styles not work separately on the title, header, and data sections of the table?
2.) How can I prevent the text style set here from affecting other existing tables in the drawing?

Many thanks!

Best Regards,
--Jeff

0 Likes
Reply
Accepted solutions (1)
784 Views
3 Replies
Replies (3)

Anonymous
Not applicable

Is this perhaps a bug?  Anyone from Autodesk?

0 Likes

CattabianiI
Collaborator
Collaborator
Accepted solution

Hi @Anonymous,

 

try to run your code, right click on your custom table --> click on Edit table style... (or something similar); now this form will appear:

 Cattura.PNG

I think you should see the same text style for Title, Column header and Data; if it is so then your code is doing the right thing and you can replicate that behaviour:

customTable.TitleTextStyle.Font = "Italic";

Inventor.Color titleTextColor = InvApp.TransientObjects.CreateColor(255, 0, 0);

customTable.TitleTextStyle.Color = titleTextColor;

click on the Title pencil and change font and color, save and come back to your custom table style

 

customTable.ColumnHeaderTextStyle.Font = "Courier New";

Inventor.Color columnHeaderTextColor = InvApp.TransientObjects.CreateColor(0, 0, 0);

customTable.ColumnHeaderTextStyle.Color = columnHeaderTextColor;

click on the Column header pencil and change font and color, save and come back to your custom table style

 

Did you get what is going on? 
You are editing the same text style, and  that text style could appear in title block, revision table and so on. So your last modification will affect all the object using that text style.

You should create thru the user interface or programmatically three text style that you'll use for Title, Column header and Data text style of the custom table.


 

Anonymous
Not applicable

Hi Isacco,

Thank you for that explanation.  That made it clearer to me about how the styles work.

Best regards,
--Jeff

0 Likes