Adjust schedule formatting


Currently, I am trying to automate the process of making schedules in Dynamo. Creating the schedule, adding fields and setting filters is going fine. The formatting of the schedule is working to an extend. I would like to change the setting from ‘No calculation’ to ‘Calculate totals’ via Dynamo (see image below from Revit schedule settings).


I am able to adjust some of the fields with nodes from Archi-Lab. The code Archi-lab used is copied below. I am able to make small adjustments to the script, mainly removing some options. Unfortunately I can’t figure out how to adjust the script to set it to ‘Calculate totals’. Is it possible to adjust this field and where can I find the correct statement to change this field?

<#Copyright© 2014, Konrad Sobon


import clr
from Autodesk.DesignScript.Geometry import *

Import DocumentManager and TransactionManager

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Import RevitAPI

import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

from System.Collections.Generic import *

Import ToDSType(bool) extension method

import Revit

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

_keySchedule = UnwrapElement(IN[0])
_paramName = IN[1]
_columnHeading = IN[2]
_hidden = IN[3]
_headingOrientation = IN[4]
_horizontalAlignment = IN[5]
_sheetColumnWidth = IN[6]

def getField(schedule, name):
definition = schedule.Definition
count = definition.GetFieldCount()
for i in range(0, count, 1):
if definition.GetField(i).GetName() == name:
field = definition.GetField(i)
return field

def formatColumn(field, heading, hidden, hOrientation, hAlign, sWidth):
message = None
if heading != None:
field.ColumnHeading = heading
if hidden != None:
field.IsHidden = hidden
if hOrientation != None:
if hOrientation == “Horizontal”:
ho = ScheduleHeadingOrientation.Horizontal
field.HeadingOrientation = ho
elif hOrientation == “Vertical”:
ho = ScheduleHeadingOrientation.Vertical
field.HeadingOrientation = ho
message = “Schedule Heading Orientation can only \nbe set to Horizontal or Vertical. \nPlease check your spelling.”
if hAlign != None:
if hAlign == “Left”:
ha = ScheduleHorizontalAlignment.Left
field.HorizontalAlignment = ha
elif hAlign == “Center”:
ha = ScheduleHorizontalAlignment.Center
field.HorizontalAlignment = ha
elif hAlign == “Right”:
ha = ScheduleHorizontalAlignment.Right
field.HorizontalAlignment = ha
message = “Schedule Horizontal Alignment can only \nbe set to Left, Center or Right. \nPlease check your spelling.”
if sWidth != None:
field.SheetColumnWidth = sWidth
return message

#“Start” the transaction

message = None
if type(_paramName) == list:
for i, j, k, l, m, n in zip(_paramName, _columnHeading, _hidden, _headingOrientation, _horizontalAlignment, _sheetColumnWidth):
scheduleField = getField(_keySchedule, i)
message = formatColumn(scheduleField, j, k, l, m , n)
scheduleField = getField(_keySchedule, _paramName)
message = formatColumn(scheduleField, _columnHeading, _hidden, _headingOrientation, _horizontalAlignment, _sheetColumnWidth)

“End” the transaction


#Assign your output to the OUT variable
if message == None:
OUT = 0
OUT = ‘\n’.join(’{:^35}’.format(s) for s in message.split(’\n’))>

Nobody knows ? I want to solve the same problem and it doesn’t seem easy…
Thanks !

Came across this thread while I was searching for a way to do this, fairly simple solution.

field = schedule.Definition.GetField(column # that you’re accessing)
field.DisplayType = ScheduleFieldDisplayType.Totals

See the Revit API for the syntax for the other calculations