# Keep group name after ungrouping

**URL:** <https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956>\
**Category:** Revit\
**Created:** [October 26, 2017, 2:37pm UTC](https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956 "2017-10-26T14:37:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![igpema](https://avatars.discourse-cdn.com/v4/letter/i/5e9695/32.png) [@igpema](https://forum.dynamobim.com/u/igpema)\
**Post date:** [October 26, 2017, 2:37pm UTC](https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956/1 "2017-10-26T14:37:49Z")

</div>

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](https://forum.dynamobim.com/uploads/short-url/sXOntjrPaIBqMVBjxrBZhArsXP2.dyn) (23.4 KB)

Thanks in advance

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/7/878a3a1fbf8f95ee6d59e82fc9dbc9f10acb38d6.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/1/311c2ee57641e8e33e3365f30f36ac2fc26b1208.png)

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [October 26, 2017, 3:36pm UTC](https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956/2 "2017-10-26T15:36:43Z")

</div>

Hi @igpema

Could you also drop your rvt file here.

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [October 26, 2017, 5:34pm UTC](https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956/5 "2017-10-26T17:34:04Z")

</div>

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

 ![Ungroup-and-preserve-group-names](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/f/afde257c1f997a1cd95282d7f7383ca33acaa5d2.png)  
(the warning is only due to elements not having a parameter to set)

---

<div class="post-metadata">

**Author:** ![igpema](https://avatars.discourse-cdn.com/v4/letter/i/5e9695/32.png) [@igpema](https://forum.dynamobim.com/u/igpema)\
**Post date:** [November 2, 2017, 10:42am UTC](https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956/6 "2017-11-02T10:42:48Z")

</div>

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

 ![04](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/e/aecc36cf9dae9adab5c73c3f87ec19bd15f49edb.JPG)

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](https://forum.dynamobim.com/uploads/short-url/7J8ZDd0mAAmDFclkszNWJ6qfPdR.dyn) (24.7 KB)  
[Test\_Ign\_05.rvt](https://forum.dynamobim.com/uploads/short-url/bAllUMS53Q3pvkGGham3XXSSeC0.rvt) (1.2 MB)

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 2, 2017, 10:59am UTC](https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956/7 "2017-11-02T10:59:51Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![igpema](https://avatars.discourse-cdn.com/v4/letter/i/5e9695/32.png) [@igpema](https://forum.dynamobim.com/u/igpema)\
**Post date:** [November 2, 2017, 12:40pm UTC](https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956/8 "2017-11-02T12:40:12Z")

</div>

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 😉

 ![5](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/3/c304418cd49191a0dbeb225c5da952b44b992c46.JPG)  
[Fassade Numerierung\_04.dyn](https://forum.dynamobim.com/uploads/short-url/x78yN6dDfWonYTbjT6qgHxyExBW.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?

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 2, 2017, 12:43pm UTC](https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956/9 "2017-11-02T12:43:47Z")

</div>

> how should I paste python files hier in Dynamobim?

See this post:

> [@How to get help on the Dynamo forums](https://forum.dynamobim.com/t/how-to-get-help-on-the-dynamo-forums/4677/10):
>
> Whenever you need help with a python script, be sure to paste the code into your post, mark it and press the \</\> button: [image]

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

---

<div class="post-metadata">

**Author:** ![igpema](https://avatars.discourse-cdn.com/v4/letter/i/5e9695/32.png) [@igpema](https://forum.dynamobim.com/u/igpema)\
**Post date:** [November 2, 2017, 1:27pm UTC](https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956/11 "2017-11-02T13:27:19Z")

</div>

hello again,

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

[Fassade Numerierung\_03.dyn](https://forum.dynamobim.com/uploads/short-url/wwCQilTrUQYTFmSqoT4HSEct5tl.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
```

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 3, 2017, 7:27pm UTC](https://forum.dynamobim.com/t/keep-group-name-after-ungrouping/15956/12 "2017-11-03T19:27:05Z")

</div>

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

> [@Editing Revit Groups with Dynamo](https://forum.dynamobim.com/t/editing-revit-groups-with-dynamo/7736/4):
>
> I suppose this can help: I successfully changed parameter values of walls into a group with ElementsInGroup from SteamNodes (no need to ungroup).
