How to force Revit to create each assembly instance with separate assembly type

I saw a Revit behaviour that when creating an assembly instance, if their elements are composed by the same families with same orientation than other assembly instances, then, Revit adds those assembly instances in the same assembly type, but I want to force that each assembly instance is in separate assembly type.
image

I used this code which I thought does the task but I saw it does not work with this rare exception.

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 System import Array

doc = DocumentManager.Instance.CurrentDBDocument
element_array = UnwrapElement(IN[0])

# get elements ids and assembly categories
ids = [[elem.Id for elem in arr] for arr in element_array]
# create list of element id lists
idlist = [List[ElementId](sublist) for sublist in ids]
# create assemblies for each sublist of elements
assembly_list = []
TransactionManager.Instance.EnsureInTransaction(doc)
for i, sublist in enumerate(idlist):
    category_id = doc.GetElement(sublist[0]).Category.Id
    assembly_instance = AssemblyInstance.Create(doc, sublist, category_id)
    assembly_list.append(assembly_instance)
TransactionManager.Instance.TransactionTaskDone()
OUT = assembly_list

I tried to see if changing some parameters value of the elements to assemble, if this behaviour would be skipped, but it does not work, I do not really know what makes this happen, I also copied and rotated elements of other assembly and I do not have clear the reasoning.

I don’t know if assigning a changed parameter would work - best to test this in the UI first, and then try in the API second.

What’s the reasoning for wanting two identical assemblies to have different types? Isn’t this increasing the work you have to do as each assembly would have to be documented uniquely instead of each type?

the elements can be the same but those are built, packed, delivered, and installed by different people at different times so everything has to be identified as different thing even if it is a copy, also by the time you create an assembly it may be identical but if may change in future anyway, so any modification you do later will create new assembly type

Ah. In this case I’d recommend using the Mark parameter for identifying the instances of each type. Otherwise you risk adding complexity where it needn’t be.

it must be assembly because the identity data of assembly name indicates where are the elements once assemblied.

I have done more tests, and it does not necessarily the fact of having same elements copied somewhere else makes the script create assembly instances with same assembly type, sometimes yes sometimes no, I do not understand this behaviour really
image

I cannot use Mark parameter for anything of assemblies, if assembly name not possible, could those built-in parameters I guess because it is what is available for assemblies in title block sheet parameter labels:
image

Can you post a model showing this? I really don’t know assemblies in the least beyond how to manipulate them with the API, so without some thing showing what you’re after I can’t clearly identify what the limit is here.

1 Like

Test.rvt (1.1 MB)


How are assembly types differentiated?
For Revit to recognize assemblies as matching, they must meet the following criteria:

  1. same value for the Naming Category property
  2. same number of elements
  3. same categories and types
  4. same values for properties that affect geometry
  5. occupy the same positions within each assembly

So looking what Revit wants, I can only customise the condition 4 because the others are impossible

1 Like

Looking this over now, and it appears the only robust solution will be to include a unique zero geometry family in each assembly to ensure it’s unique.

However I still don’t understand the issue with the parameters so I’m not sure that’ll solve the issue or just bloat the model and create something impossible to manage well. Can you upload a version of the model showing the full use of one of the parameters above in the context of the current dataset?

did you say add a family with zero geometry? if that is the case it will be detected as identical than other list of elements because geometry is same. I see a problem doing that because cannot control afterwards where are those objects as the model is always a work in progress.

because I do not care of Revit wants, I had to invent something, edit Revit loadable families, add a reference line and associate its length with a new shared parameter that I am going to tweak with Dynamo to make different number for each list of elements that I want to add to an assembly.

I tried project parameters of Length applied on all categories and system families but it did not work, so I am forced to use loadable families if I want this work, but this task need manual input before using Dynamo so I would like to avoid to create too many custom families just for that

Unique types prevent this, but yes the inability to control the location in the UI could be problematic.

While these steps would resolve the issue for you today, it will not prevent the inevitable update from causing the issue to occur again, as a new instance of an exiting assembly will not be unique. Finding another way around the parameter limit is likely a better solution, but I am not sure what that could be as I don’t’ understand the use/limitation.