# Creating assemblies

**URL:** <https://forum.dynamobim.com/t/creating-assemblies/26528>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [November 1, 2018, 5:00am UTC](https://forum.dynamobim.com/t/creating-assemblies/26528 "2018-11-01T05:00:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noes](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Noes](https://forum.dynamobim.com/u/Noes)\
**Post date:** [November 1, 2018, 5:00am UTC](https://forum.dynamobim.com/t/creating-assemblies/26528/1 "2018-11-01T05:00:00Z")

</div>

Hey there!

I just started getting used to the basic ideas of Dynamo and wrote my first scripts. This time however, it looks like I’m way off and far from a solution.

I’ve made an excel list with assembly names, sheet names and sheet numbers. I split the list, used the three outputs as input.  
However, my script does not create any assembly at all. It looks good until the ‘assembly instance create’ node. I’ve been wondering for some days what i’ve been doing wrong, tried some other solutions like the ‘tool create assembly’ and tried with and without using a level on the ‘assembly instance create’ node, but this doesn’t help either.

Anyone who can help me out?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/7/57ec095ac3942a948cb53ac352d2ea52e356ada7.jpeg)

---

<div class="post-metadata">

**Author:** ![Bjorn\_Keulemans1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bjorn_keulemans1/32/54676_2.png) [@Bjorn\_Keulemans1](https://forum.dynamobim.com/u/Bjorn_Keulemans1)\
**Post date:** [November 1, 2018, 9:53am UTC](https://forum.dynamobim.com/t/creating-assemblies/26528/2 "2018-11-01T09:53:51Z")

</div>

Your Assembly Node is a custom Node and it looks like you’re using Dynamo 2.0. Is that package updated for 2.0?

---

<div class="post-metadata">

**Author:** ![Rabindra\_Adhikari](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rabindra_adhikari/32/31788_2.png) [@Rabindra\_Adhikari](https://forum.dynamobim.com/u/Rabindra_Adhikari)\
**Post date:** [November 2, 2018, 7:25am UTC](https://forum.dynamobim.com/t/creating-assemblies/26528/3 "2018-11-02T07:25:24Z")

</div>

See if this helps. Thanks!

 ![Create%20Assembly%20snip01](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/5/b5cf98b380f67493df4100591a42ff200f07ba4b.png)

---

<div class="post-metadata">

**Author:** ![Noes](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Noes](https://forum.dynamobim.com/u/Noes)\
**Post date:** [November 4, 2018, 11:13pm UTC](https://forum.dynamobim.com/t/creating-assemblies/26528/4 "2018-11-04T23:13:17Z")

</div>

Thanks for the fast replies! The node I’ve been trying to use is indeed from the package with the 1.2.2 version, while I’m using Dynamo 2.0. I tried to edit the node but this doesn’t seem to work…  
I also tried the solution suggested by @Rabindra_Adhikari , but this didn’t work either.

Any other suggestions?

---

<div class="post-metadata">

**Author:** ![MJB-online](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mjb-online/32/24884_2.png) [@MJB-online](https://forum.dynamobim.com/u/MJB-online)\
**Post date:** [November 4, 2018, 11:55pm UTC](https://forum.dynamobim.com/t/creating-assemblies/26528/5 "2018-11-04T23:55:16Z")

</div>

Hi @Noes,

I think the method by @Rabindra_Adhikari, will work when you add a “Transaction.End” node.

 ![CreateAssemblies](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/f/bf533a83f8126aec4d4edc104de6d880187dd032.png)

Kind regards,  
Mark

---

<div class="post-metadata">

**Author:** ![Noes](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Noes](https://forum.dynamobim.com/u/Noes)\
**Post date:** [November 5, 2018, 9:22pm UTC](https://forum.dynamobim.com/t/creating-assemblies/26528/6 "2018-11-05T21:22:09Z")

</div>

I tried again but it didn’t work out… I took a closer look to the ‘tool create assembly’ and this is how the costum node is made. Not sure, but could this be the problem? If so, how can I fix it?

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/f/7fdcf72867f3c70ed4304dc4796e3f44cf2183e1.png)

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [November 5, 2018, 9:24pm UTC](https://forum.dynamobim.com/t/creating-assemblies/26528/7 "2018-11-05T21:24:22Z")

</div>

You can replace `Flatten([a])` by `DSCore.List.Flatten(a,-1);`

---

<div class="post-metadata">

**Author:** ![Noes](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Noes](https://forum.dynamobim.com/u/Noes)\
**Post date:** [November 8, 2018, 1:05am UTC](https://forum.dynamobim.com/t/creating-assemblies/26528/8 "2018-11-08T01:05:14Z")

</div>

Okay so, I replaced the Flatten([a]) by DSCore.List.Flatten(a,-1); in all the costrum nodes. Thanks for that, because now this warning is gone!

But still, my assemblies were not created. It seems like the ‘create assembly tool’ doesn’t do its job and I’m still struggling to find out why

---

<div class="post-metadata">

**Author:** ![Noes](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Noes](https://forum.dynamobim.com/u/Noes)\
**Post date:** [December 5, 2018, 11:50pm UTC](https://forum.dynamobim.com/t/creating-assemblies/26528/9 "2018-12-05T23:50:38Z")

</div>

So, almost a month later I haven’t solved this problem. I think the problem lies within the python script of the Assamblyinstance.create node, I can’t think of any other problem. However, I’m not familiar at all with Python, so I hope that someone can help me out with this one!

> import clr  
> import sys
> 
> clr.AddReference("RevitNodes")  
> import Revit  
> clr.ImportExtensions(Revit.GeometryConversion)
> 
> #Import Dynamo Revit Libraries ‘RevitServices’ Namespace#  
> clr.AddReference(‘RevitServices’)  
> import RevitServices  
> from RevitServices.Persistence import DocumentManager  
> from RevitServices.Transactions import TransactionManager
> 
> clr.AddReference("RevitAPI")  
> import Autodesk  
> from Autodesk.Revit.DB import \*
> 
> from System.Collections.Generic import \*
> 
> doc = DocumentManager.Instance.CurrentDBDocument  
> app = DocumentManager.Instance.CurrentUIApplication.Application
> 
> data = IN
> 
> assembly\_category = UnwrapElement(IN[1])
> 
> t = Transaction(doc)
> 
> was\_created = False  
> t.Start("Create Assembly Instance")  
> try:  
> assembly\_created = AssemblyInstance.Create(doc, List[ElementId](map(lambda x: x.Id, UnwrapElement(IN[2]))), assembly\_category.Id)  
> was\_created = True  
> t.Commit()  
> except:  
> was\_created = False  
> t.RollBack()
> 
> if was\_created:  
> if t.GetStatus() == TransactionStatus.Committed:  
> t.Start("Set Assembly Name")  
> assembly\_created.AssemblyTypeName = str(IN[0])  
> t.Commit()  
> else:  
> assembly\_created = "Assembly couldn’t be created. Ensure assembly can be created through the UI or contact us for assistance."
> 
> # Assign your output to the OUT variable.
> 
> OUT = assembly\_created

Thanks in advance!
