Adding Calculated Parameter using Revit API

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()

hi @NIRMAL

you are on right track, here InsertCombinedParameterField Method (revitapidocs.com) , using this method u can add the formula u looking for it takes “ScheduleFieldType” which is an Enumeration and i think this will get u to what u trying to do.

Regards,
BM

It is still unclear path for me.
The method InsertCombinedParameterField Method doesn’t do the calculation and it does not take the ScheduleFieldType enumeration as input

An example of how we can use this enumeration to add a calculated field will be very helpful.

Hi,

Unless recently changed, this is not supported by the API.

see here

2 Likes

Even i was trynna achieve this using that enumeration and creating a schedulable field but no success @NIRMAL i’ll still be looking and will keep u posted here :cry: