Keep group name after ungrouping

#1

Hello Dyn community,

I want to set a parameter within a group, I succeded by ungrouping, doing the changes within the group and after grouping these elements again.
But I can not give the right name to the group and maybe is cause I am not using the Passthrough node from Clockworks correctly. Any Ideas?
Fassade Numerierung.dyn (23.4 KB)

Thanks in advance


0 Likes

#2

Hi @igpema

Could you also drop your rvt file here.

1 Like

#4

@igpema I dont think it is the passThrough that is the problem, you have an empty list problem before you come to that node. try to focus on why your “set parameter” node gives empty list.

1 Like

#5

Here is a simplified workflow using an Excel file to retain group names that could work as a basic example:


(the warning is only due to elements not having a parameter to set)

2 Likes

#6

Thanks for the replies,

I sorted out the problem of empty lists by using a second Passthrough. Before ungrouping i needed to obtain the group members and then ungroup.
Although the problem is the same, the new groups dont take the name they should, i tried out with export in excel as Yna_Db propposed, but the problem is still there. I think the problem is that the Python skript of the node doesnt work out properly with my list structure. I think the node Group.FromElements is prepare to create only one group but not serveral groups with several names, at least that is my opinion after looking at the code… although I am not good at python…

As a second option that I am going to try is to do a second dyn. file and rename the groups with the excel list system from Yna_Db.

Attacht is also the dyn and the revit file.

thanks in advance

The Python script from Group.fromElements:

doc = DocumentManager.Instance.CurrentDBDocument
items = UnwrapElement(IN[0])
ids = list()
rejects = list()
for item in items:
—try:
------ids.append(item.Id)
—except:
------rejects.append(item)
items = List[ElementId] (ids)

TransactionManager.Instance.EnsureInTransaction(doc)
try:
—group = doc.Create.NewGroup(items);
—group.GroupType.Name = IN[1]
except:
—group = list()
TransactionManager.Instance.TransactionTaskDone()

OUT = (group,rejects)

Fassade Numerierung_02.dyn (24.7 KB)
Test_Ign_05.rvt (1.2 MB)

0 Likes

#7

I am not totally sure the Excel workflow example would work as such to maintain identical group names, I noticed afterwards that the groups numbers were incremented. I did not have time yet to experiment further but I thought of using wether a BakeElements node from Rhythm or trying not only to delete groups by ungrouping them but also to delete associated group types. I will be interested in your results anyway…

0 Likes

#8

well,
I just did a second dyn.file and like that work out. It is for sure not the best solution but at least I can go on :wink:


Fassade Numerierung_04.dyn (12.0 KB)

And the Python file:

doc = DocumentManager.Instance.CurrentDBDocument
names = IN[0]
groups = UnwrapElement(IN[1])

TransactionManager.Instance.EnsureInTransaction(doc)

for name,group in zip(names,groups):
—try:
------group.GroupType.Name = name
—except:
------group = list()

TransactionManager.Instance.TransactionTaskDone()

OUT = (groups,names)

By the way, how should I paste python files hier in Dynamobim?

0 Likes

#9

how should I paste python files hier in Dynamobim?

See this post:


I think this workflow in its current state does not ensure that the right name goes to the right group…

0 Likes

#11

hello again,

the problem was the Python file from the node Group.FromElements. Now it is workig.

Fassade Numerierung_03.dyn (22.6 KB)

doc = DocumentManager.Instance.CurrentDBDocument
elements = UnwrapElement(IN[0])
gNames = IN[1]

items = []
ids = []
rejects = list()
group = []

TransactionManager.Instance.EnsureInTransaction(doc)

for element,gName in zip(elements,gNames):
	for ele in element:
		try:
			ids.append(ele.Id)
		except:
			rejects.append(element)
	items = List[ElementId](ids)
	try:
		group = doc.Create.NewGroup(items);
		group.GroupType.Name = gName
	except:
		group = list()
		
TransactionManager.Instance.TransactionTaskDone()

OUT = elements
0 Likes

#12

There is additional information on this topic in this thread for anyone interested:

1 Like