Create calculated formula Schedule

Hey there,

I’m trying to use dynamo to create calculated formula’s in schedules. I looked into the RevitAPIDocs, but I can’t seem to find a method for this. Does anyone know whether this is even possible at all?

Kind regards
Pieter

Try this with a Formula ScheduleFieldType.

Good idea, but I get this error:
Exception: fieldType is not a schedulable field type
Parameter name: fieldType

If I use Count in stead of Formula, everything works fine.

Hi @pieter.lamoen and welcome, can you share/ post your code so we can help you?

This is my python code:

# Import libraries
import sys
import clr

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import*

# Import System Enum
import System
from System.Collections.Generic import*

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Transactions import TransactionManager
from RevitServices.Persistence import DocumentManager
# Define Current Document
doc = DocumentManager.Instance.CurrentDBDocument


# /// This is where the fun starts ///
# INPUT
schedule = UnwrapElement(IN[0])
# or input1 = UnwrapElement(IN[0])

# CODE
s_def = schedule.Definition

#TRANSACTION
TransactionManager.Instance.EnsureInTransaction(doc)

s_def.AddField(ScheduleFieldType.Formula)

TransactionManager.Instance.TransactionTaskDone()

# OUTPUT
OUT = schedule

image