Creating Assemblies - Not working, no Errors though

I believe I granted you access last night. Let me know if you are still having issues accessing the file.

Still seeing a "you don’t have access’ on my end. Not sure who you provided a link to. Feel free to DM me if it helps.

saving this for future use.
image

3 Likes

Ah, this set of nested lists is what makes it harder to work in python.

That is part of the reason why clockwork has a turnIntoList node that just drops all the structure.

However, I think you need to maintain that list, so this would be a use-case of a def in python I believe. I am not amazing at python, but I can take a look.

1 Like

Another discovery https://spiderinnet.typepad.com/blog/2016/09/revit-net-api-group-and-assembly-creation-and-name-setting.html

So it turns out that the Revit API throws out assemblies that are being created when they are invalid. It looks like some elements might be being reused between the assemblies?

ahh… this is in the UI. So we are seeing that your curtain panel instances are matching in your sample file, so it is using the last one created at this point.
I will attach my sample in a moment.
image

When I test it on my sample project it says that all elements are unique

Yeah, they are. Check my last reply. Creating Assemblies - Not working, no Errors though - #28 by john_pierson

I changed the length of one of your storefronts and it is now unique. Revit does some magic to see if it matches.

There is a cool compare instances api too: ApiDocs.co

So there is an issue where I’m trying to name them all individually, but in fact there will be instances where multiple assemblies will have the same name because they are in fact the same (like from floor to floor).
This is a separate issue from the sub-list though, correct? Because even when I made all 3 different sizes I still got the same error when trying to run the script.
You are saying that added into the script needs to be something that addresses duplicate assembly types?

1 Like

Yes.

I think I have something that at least works with the sublists. Standby

I would definitely take the naming of the assemblies out of the original creation and worry about it later by just collecting the assembly types. I left it in place for the graph below, but it isn’t used in my python.

here is my graph:


createAssembliesForCurtainWalls.dyn (42.0 KB)

import clr
from System.Collections.Generic import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from itertools import groupby
import operator

doc = DocumentManager.Instance.CurrentDBDocument
element_array = UnwrapElement(IN[0])
assembly_names = IN[1]
assembly_list = list()

#function to create assemblies
def CreateAssembly(elementList):
	currentAssemblyInstanceId = ElementId.InvalidElementId
	ids = list()
	for element in elementList:
		ids.append(element.Id)
	idlist = List[ElementId](ids)
 	TransactionManager.Instance.ForceCloseTransaction()
  
	TransactionManager.Instance.EnsureInTransaction(doc)
	newAssemblyInstance = AssemblyInstance.Create(doc, idlist, elementList[0].Category.Id)
	currentAssemblyInstanceId = newAssemblyInstance.Id
 	TransactionManager.Instance.TransactionTaskDone()
	return newAssemblyInstance

# create assemblies
for sublist in element_array:
	# use our function to append a new assembly to the list
	assembly_list.append(CreateAssembly(sublist))
 


OUT = assembly_list
3 Likes

Awesome, thank you so much! So I ran it in my sample project and it worked like it should.

I ran it in my project and ran into some issues there. As best as I can tell it seems like there are residual assemblies or something that are causing issues. I created new assemblies but it only made 13 instead of 94, it named them using the storefront naming system, and there were some errors in dynamo that didn’t appear when running it on the sample project.

I tried looking in purge unused and using Ideate BIMlink to export all the assemblies to see if there was anything living in the background. I couldn’t find anything. Any suggestions on cleaning up the file?

image


there be a few in-place families in yer project matey.

1 Like

This will fix it.


createAssembliesForCurtainWalls.dyn (45.8 KB)

Looks like only 1,676 of them…

2 Likes

2 Likes

The error in collecting the walls is gone but the error for the panels is still there.


As well as the error at the Python Script.

Why is there an error when it looks like the node did what it was supposed to do?
Sorry about dragging you into our messy model.