Creating assemblies

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?

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

See if this helps. Thanks!

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?

Hi @Noes,

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

Kind regards,
Mark

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

1 Like

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

1 Like

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

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!