Elements from rows in schedule

Hi all, I have a schedule in Revit (windows table somehow filtered and sorted), and I need in Dynamo to get a list of sublists, where in every sublist wilb be all elements on one row of schedule (similar to Schedule.GetDataRow, but output will be elements instead of data).
Schedule is like this:
OK1
Last column is Count, so first sublist will have 1 element, fifth sublist will have 48 elements etc.
Thanks for help

Hi @Peter_Jirat,
Welcome to the Dynamo community.

You can do something like this with Python: GetSorted GroupedScheduleElements.dyn (29.8 KB)

import clr
clr.AddReference("RevitAPI","RevitServices")
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

scheduleView = UnwrapElement(IN[0])
scheduleDefinition = scheduleView.Definition
scheduleParameters = ScheduleDefinition.GetSortGroupFields(scheduleDefinition)
elements = FilteredElementCollector(doc,scheduleView.Id).ToElements()

paraVals = []

for scheduleParameter in scheduleParameters:
	parameter = scheduleDefinition.GetField(scheduleParameter.FieldId).GetName()
	temp = []
	for element in elements:
		instParaVal = element.LookupParameter(parameter)
		if instParaVal:
			temp.append(instParaVal.AsString())
		else:
			temp.append(doc.GetElement(element.GetTypeId()).LookupParameter(parameter).AsString())
	paraVals.append(temp)

keys = ['|'.join(z) for z in zip(*paraVals)]
sortedKeys = sorted(set(keys))

OUT = [[elekey[0] for elekey in zip(elements,keys) if elekey[1]==key] for key in sortedKeys]
1 Like

@Peter_Jirat If that doesn’t work out, you can install some custom packages [Data-Shapes & Rhythm] and do something as shown below. GetSorted GroupedScheduleElements.dyn (29.8 KB)

Hi @AmolShah , thanks for your node solution script, works fine with small changes for more then 2 sorting parameters. Any idea how to get a list of all sorting parameters from a schedule?
Python gives me some string error:

@Peter_Jirat Ignore the Python solution. It’s a work in progress.

For the node based solution, I’ve added a python node to get all sorting parameters.
GetSortedGroupedScheduleElements.dyn (22.1 KB)

1 Like

Hi, this is EXACTLY what I needed. Thanks

1 Like

how can I get the parameter ID and the parameter itself of the schedule fields to query it later? I want to know more about the parameters, not the elements. I think it is not far from what I see in the script

If still relevant to someone

field = scheduleDefinition.GetField(scheduleParameter.FieldId)
parameter_id = field.ParameterId
parameters = doc.GetElement(parameter_id)
1 Like