Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting a Schedules Header Styles

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Rockit_for_Revit
332 Views, 5 Replies

Getting a Schedules Header Styles

Rockit_for_Revit
Advocate
Advocate

Hello,

I would like to get the style overides for the body headers of a schedule. However when I use this function, it does not return the correct values for font name, justification etc it seems size cannot be overidden.

Dim objScheduleDefinition As ScheduleDefinition = objViewSchedule.Definition
Dim ListOfRows As New List(Of String)
strRowHedding = "Headers" & clsReadWrite.strPublicConstCSVsepp & "Styles"
For Each objScheduleFieldId As ScheduleFieldId In objScheduleDefinition.GetFieldOrder
    Dim objScheduleField As ScheduleField = objViewSchedule.Definition.GetField(objScheduleFieldId)
    If Not objScheduleField.IsHidden Then
        Dim objFormatOptions As FormatOptions = objScheduleField.GetFormatOptions
        Dim objTableCellStyle As TableCellStyle = objScheduleField.GetStyle
        Dim objHorizontalAlignmentStyle As HorizontalAlignmentStyle = objTableCellStyle.FontHorizontalAlignment
        Dim objVerticalAlignmentStyle As VerticalAlignmentStyle = objTableCellStyle.FontVerticalAlignment
        Dim strFontName As String = objTableCellStyle.FontName
        Dim bolIsFontBold As Boolean = objTableCellStyle.IsFontBold
        Dim bolIsFontItalic As Boolean = objTableCellStyle.IsFontItalic
        Dim bolIsFontUnderline As Boolean = objTableCellStyle.IsFontUnderline
objViewSchedule.Document.GetElement(objViewSchedule.HeaderTextTypeId).Name
        Dim dblTextSize As Double = Math.Round(objTableCellStyle.TextSize / 3.77952756, 1, MidpointRounding.AwayFromZero)
        strRowHedding = strRowHedding & clsReadWrite.strPublicConstCSVsepp & Chr(34) & objScheduleField.ColumnHeading & "|" & strFontName & "|" & dblTextSize & "|Bold:" & bolIsFontBold & "|Underline:" & bolIsFontUnderline & "|Horiz:" & objHorizontalAlignmentStyle.ToString & "|Vert:" & objVerticalAlignmentStyle.ToString & Chr(34)
    End If
Next

 Kind Regards
David

0 Likes

Getting a Schedules Header Styles

Hello,

I would like to get the style overides for the body headers of a schedule. However when I use this function, it does not return the correct values for font name, justification etc it seems size cannot be overidden.

Dim objScheduleDefinition As ScheduleDefinition = objViewSchedule.Definition
Dim ListOfRows As New List(Of String)
strRowHedding = "Headers" & clsReadWrite.strPublicConstCSVsepp & "Styles"
For Each objScheduleFieldId As ScheduleFieldId In objScheduleDefinition.GetFieldOrder
    Dim objScheduleField As ScheduleField = objViewSchedule.Definition.GetField(objScheduleFieldId)
    If Not objScheduleField.IsHidden Then
        Dim objFormatOptions As FormatOptions = objScheduleField.GetFormatOptions
        Dim objTableCellStyle As TableCellStyle = objScheduleField.GetStyle
        Dim objHorizontalAlignmentStyle As HorizontalAlignmentStyle = objTableCellStyle.FontHorizontalAlignment
        Dim objVerticalAlignmentStyle As VerticalAlignmentStyle = objTableCellStyle.FontVerticalAlignment
        Dim strFontName As String = objTableCellStyle.FontName
        Dim bolIsFontBold As Boolean = objTableCellStyle.IsFontBold
        Dim bolIsFontItalic As Boolean = objTableCellStyle.IsFontItalic
        Dim bolIsFontUnderline As Boolean = objTableCellStyle.IsFontUnderline
objViewSchedule.Document.GetElement(objViewSchedule.HeaderTextTypeId).Name
        Dim dblTextSize As Double = Math.Round(objTableCellStyle.TextSize / 3.77952756, 1, MidpointRounding.AwayFromZero)
        strRowHedding = strRowHedding & clsReadWrite.strPublicConstCSVsepp & Chr(34) & objScheduleField.ColumnHeading & "|" & strFontName & "|" & dblTextSize & "|Bold:" & bolIsFontBold & "|Underline:" & bolIsFontUnderline & "|Horiz:" & objHorizontalAlignmentStyle.ToString & "|Vert:" & objVerticalAlignmentStyle.ToString & Chr(34)
    End If
Next

 Kind Regards
David

5 REPLIES 5
Message 2 of 6

jeremy_tammik
Autodesk
Autodesk

It is hard to say anything offhand. What values you expect to see, and what values do you actually observe?

  

Can you share a complete minimal reproducible case for analysis?

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

It is hard to say anything offhand. What values you expect to see, and what values do you actually observe?

  

Can you share a complete minimal reproducible case for analysis?

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 6

Rockit_for_Revit
Advocate
Advocate

Thank you for your reply. Following is an image of a test schedule from an attached sample model:

Rockit_for_Revit_1-1724800937907.png

 

Following are the results. I'm getting correct results from the title (Header) section, but not from the field title where I have overridden the justification to top right and the font.

Bahnschrift|5|Bold:True|Underline:True|Horiz:Center|Vert:Middle
Mark (Right Top)|Arial|2.4|Bold:False|Underline:False|Horiz:Left|Vert:Middle

 

Kind Regards

David

 

 

0 Likes

Thank you for your reply. Following is an image of a test schedule from an attached sample model:

Rockit_for_Revit_1-1724800937907.png

 

Following are the results. I'm getting correct results from the title (Header) section, but not from the field title where I have overridden the justification to top right and the font.

Bahnschrift|5|Bold:True|Underline:True|Horiz:Center|Vert:Middle
Mark (Right Top)|Arial|2.4|Bold:False|Underline:False|Horiz:Left|Vert:Middle

 

Kind Regards

David

 

 

Message 4 of 6

jeremy_tammik
Autodesk
Autodesk

Thank you for the sample material. I passed them on to the development team for analysis..

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

Thank you for the sample material. I passed them on to the development team for analysis..

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 5 of 6

jeremy_tammik
Autodesk
Autodesk
Accepted solution

They reply: 

     

The TableCellStyle of ScheduleField is for the whole column of the body section of the schedule, while the body header may have a different TableCellStyle if overridden. To retrieve header styles, there is no direct API exposed in the schedule. The only way I can think of is to use GetTableCellStyle:

  

  

It needs to be called in Body section and the user needs to know which row and column is the header.

    

Example code:

   

  TableCellStyle objTableCellStyle = objViewSchedule
    .GetTableData()
    .GetSectionData(SectionType.Body)
    .GetTableCellStyle(0, 0);

      

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

They reply: 

     

The TableCellStyle of ScheduleField is for the whole column of the body section of the schedule, while the body header may have a different TableCellStyle if overridden. To retrieve header styles, there is no direct API exposed in the schedule. The only way I can think of is to use GetTableCellStyle:

  

  

It needs to be called in Body section and the user needs to know which row and column is the header.

    

Example code:

   

  TableCellStyle objTableCellStyle = objViewSchedule
    .GetTableData()
    .GetSectionData(SectionType.Body)
    .GetTableCellStyle(0, 0);

      

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 6 of 6

Rockit_for_Revit
Advocate
Advocate

Thank you that's it.

0 Likes

Thank you that's it.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report