I am having a very hard time trying to solve this Problem.
I got these two lists:
And my goal is to combine these two lists before grouping them.
For instance it should look like that after combining: 0 Takt 1 395386
So basically i don’t want to loose the Element ID but also have the Element.Name for being able to sort it alphanumerically and filtering it by that Element.Name 
This is what i’ve been trying, but i am loosing the Element ID doing it that way.
or with python script:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import python library
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import os
# Import math library
from math import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# Import Element nodes in Dynamo
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import DSCore nodes in Dynamo
clr.AddReference('DSCoreNodes')
import DSCore
from DSCore import *
#Import System Library
import System
from System.Collections.Generic import *
from System.IO import Directory
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
#Preparing input from dynamo to revit
list1 = UnwrapElement(IN[0])
list2 = UnwrapElement(IN[1])
newlist = []
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for l1,l2 in zip(list1,list2):
newlist.append(l1+" "+str(l2))
TransactionManager.Instance.TransactionTaskDone()
#Final output
OUT = DSCore.List.GroupByKey(newlist, list1)
ah then i think you gotta rename the type family of the element.
PS. can i know what is inside the python script of your graph?
Well… is there an easy way to do it with Dynamo?
The problem is: The lists aren’t in that structure i want them to be. That’s why i need to sort and filter it. To do so, i need the “Takt X” Element.Name …
If i combine the two lists, loosing the Element ID i can’t get any Parameter Values by name afterward.
If there is a way to sort/filter it in any other way it would be accaptable too!
well, if you want to get your parameter, then what you are doing is fine. just feed through the element’s parameter node. But if you to rename to takt, then you can use @erfajo package, orchid, rename family type base on your list, or any other custom node available 
If you only need the name for sorting purposes, you can use sort by key node, where the list are the elements and the keys are the names. Is there a reason to need the element id as a string?
I tried sorting it by key before group by key. But then the lists are incorrect…
The assignment no longer fits 
What is the outcome you are looking for? Right now, you are using the wrong list as the list input. Do you want groups of same name elements with the overall list sorted by name?
I want the Elements of each Phase grouped by their Phase (doing so in the second one).
To improve the Script i want the Phases to be filtered/sorted before grouping their Elements
Just came up with an idea, didn’t tried it yet though:
Using the Script as i did before - after grouping the elements getting the ParameterValueByName - combining Phase-list with new ParameterValue-List - sorting/filtering it - delete PhaseNames out of the ParameterValue-list
Should work?
Try this. Plug in the output of the All Elements of Category node into the list input of List.SortByKey and the output of element.name as the keys input.
1 Like
This actually works! Thank you!
One more thing … since i got more than 9 Phases it counts them as 1-10-11-12-13-14-15-16-17-18-19-2-20-21- …
It should be 1-2-3-4-5-6-7-8-9-10-11-…
Doesn’t work for SortByKey yet
Convert to a string, then pad left with 0s.