SetCellStyleOverrideOptions Method


Table Cell Style Set Cell Style Override Options Method

Sets cell style override options of this cell.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public void SetCellStyleOverrideOptions(
	TableCellStyleOverrideOptions helper
)

Parameters

helper TableCellStyleOverrideOptions
Exceptions
Exception Condition
ArgumentNullException A non-optional argument was null
Example
public static void ApplyFormattingToField(ViewSchedule schedule, int fieldIndex)
{
    // Get the field.
    ScheduleDefinition definition = schedule.Definition;
    ScheduleField field = definition.GetField(fieldIndex);

    // Build unit formatting for the field.
    FormatOptions options = field.GetFormatOptions();
    options.UseDefault = false;
    options.SetUnitTypeId(UnitTypeId.SquareInches);
    options.SetSymbolTypeId(SymbolTypeId.InSup2);

    // Build style overrides for the field
    // Use override options to indicate fields that are overridden and apply changes
    TableCellStyle style = field.GetStyle();
    TableCellStyleOverrideOptions overrideOptions = style.GetCellStyleOverrideOptions();
    overrideOptions.BackgroundColor = true;
    style.BackgroundColor = new Color(0x00, 0x00, 0xFF);
    overrideOptions.FontColor = true;
    style.TextColor = new Color(0xFF, 0xFF, 0xFF);
    overrideOptions.Italics = true;
    style.IsFontItalic = true;

    style.SetCellStyleOverrideOptions(overrideOptions);

    double width = field.GridColumnWidth;

    using (Transaction t = new Transaction(schedule.Document, "Set style etc"))
    {
        t.Start();
        field.SetStyle(style);
        field.SetFormatOptions(options);
        // Change column width (affects width in grid and on sheet) - units are in Revit length units - ft.
        field.GridColumnWidth = width + 0.5;
        t.Commit();
    }
}
See Also
ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →