Schedule Parameters

Hello Dynamo friends :slight_smile:

I´m setting a bunch of schedule parameters successfuly. I can hide fileds, add filters, set formatting, grand totals, itemize every instance…

But i have some trouble with the following ones:

1) Set Text Type - Can´t get this archilab node to work, the python script is from the node.

2) Calculate Totals - found a python code here on the forum but it doesn´t work:

import clr
clr.AddReference(‘RevitAPI’)
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
from Revit.Elements import *
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.GeometryReferences)

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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

view = doc.ActiveView

def U(elem):
a = UnwrapElement(elem)
return a

schedule = UnwrapElement(IN[0])
colName = IN[1]

definit = schedule.Definition
countParameters = definit.GetFieldCount()

Parameter names
names = 
for i in range(countParameters):
Parname = definit.GetField(i).ColumnHeading # Parameter Column name
if Parname == colName:
index = i

field = schedule.Definition.GetField(index) # schedule field
TransactionManager.Instance.EnsureInTransaction(doc)

field.DisplayType = ScheduleFieldDisplayType.Totals

TransactionManager.Instance.TransactionTaskDone()
OUT = field

3) I´d like to hide the Schedule Title, can´t find any code for that.

Happy about any help :slight_smile:

1 Like

i dont know what exactly you try, but the python template looks this way:
Can you discribe it better? count schedules?

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

Hey @Draxl_Andreas

I want to

  • Set Text Type
  • hide the title and
  • calculate totals

image

image

Which Revit do you use?

Could be your Revit API does not support schedule title.

Calculate Totals works now :slight_smile:
Only 2 problems left to solve.

image

import clr

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

#Import the Revit Services
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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

def U(elem):
	a = UnwrapElement(elem)
	return a

schedule = UnwrapElement(IN[0])
colNum = IN[1]

definit = schedule.Definition
countParameters = definit.GetFieldCount()


field = schedule.Definition.GetField(colNum) # schedule field
TransactionManager.Instance.EnsureInTransaction(doc)

field.DisplayType = ScheduleFieldDisplayType.Totals

TransactionManager.Instance.TransactionTaskDone()
OUT = field

I`m using 2021 and 2022, but the TextTypeId Property should work with all versions:

But I´m still getting that strange error when i try to set the texttype.

Hiding the title should also work with the API:

hello @gerhard.p

try this

import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

toList = lambda x : x if hasattr(x, '__iter__') else [x]

#Preparing input from dynamo to revit
lstviews = toList(UnwrapElement(IN[0]))
txtStyle = UnwrapElement(IN[1])


#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for v in lstviews:
	if v.ViewType == ViewType.Schedule:
		v_def = v.Definition 
		v.BodyTextTypeId  = txtStyle.Id
		v.HeaderTextTypeId  = txtStyle.Id
		v.TitleTextTypeId = txtStyle.Id
		#
		v_def.ShowTitle = False
		count = v_def.GetFieldCount()
		for i in range(count):
			field = v_def.GetField(i)
			if field.CanTotal():
				field.DisplayType = ScheduleFieldDisplayType.Totals

TransactionManager.Instance.TransactionTaskDone()

OUT = lstviews
3 Likes

Amazing, thank you so much @c.poupin :smiley:

I added the following:

  • Don`t itemize every instance
  • Show grand totals
  • Grand totals title
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

toList = lambda x : x if hasattr(x, '__iter__') else [x]

#Preparing input from dynamo to revit
lstviews = toList(UnwrapElement(IN[0]))
txtStyle = UnwrapElement(IN[1])


#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for v in lstviews:
	if v.ViewType == ViewType.Schedule:
		v_def = v.Definition 
		#Set Text Type
		v.BodyTextTypeId  = txtStyle.Id
		v.HeaderTextTypeId  = txtStyle.Id
		v.TitleTextTypeId = txtStyle.Id
		#Hide Title
		v_def.ShowTitle = False
		#Don´t itemize every instance
		v_def.IsItemized = False
		#Show grant totals
		v_def.ShowGrandTotal = True
		v_def.ShowGrandTotalTitle = True
		v_def.GrandTotalTitle = "SUMME"
		count = v_def.GetFieldCount()
		for i in range(count):
			field = v_def.GetField(i)
			if field.CanTotal():
				field.DisplayType = ScheduleFieldDisplayType.Totals

TransactionManager.Instance.TransactionTaskDone()

OUT = lstviews
3 Likes

So the last step would be to activate the outline of the schedule, but i can´t find that in the API, i´m afraid i have to do that with the viewtemplate…

I believe this property is not exposed to the Revit API

Luckily this setting can be controlled with the viewtemplate :slight_smile: