Hello,
I am having trouble adding a calculated parameter to a schedule using the Revit API.
Attempted to create schedules using Python in Dynamo. While I successfully created a new Material Takeoff and added parameters to the schedule, I couldn’t locate a method for adding a calculated column in schedules.
desiredParams = ["***", "Type","Material: Name", "************", "Length","Calculated Weight", "Structural Usage"]
OUT = []
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
cat = Category.GetCategory(doc, BuiltInCategory.OST_StructuralColumns)
viewSchedule = ViewSchedule.CreateMaterialTakeoff(doc, cat.Id)
definition = viewSchedule.Definition
params = [i.GetName(doc) for i in definition.GetSchedulableFields()]
schedulableFields = definition.GetSchedulableFields()
for j in desiredParams:
if j in params:
ind = params.IndexOf(j)
definition.AddField(schedulableFields[ind])
OUT.append(j + " Added")
elif j == "Calculated Weight":
else:
OUT.append(j + " Not founds")
TransactionManager.Instance.TransactionTaskDone()