Finding out which assembly a view belongs to?

I would like to manipulate my assembly views, but I can’t find a reference to the assemblies in the Element.Parameter node. There is nothing that indicates that an assembly view actually is an assembly view. Type Id is the same for all the assembly views, but it’s different from the Type Id of the assembly. Surely they are associated with each other in some way?

@Geodude1

did you try this ? you need to reverse this, get from the view the assembly ID ?

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

def get_assembly_views(doc, assembly_instance_id):
    # 0️⃣ whether list or not
    if not isinstance(assembly_instance_id, ElementId):
        assembly_instance_id = ElementId(assembly_instance_id)

    # 1️⃣ Get the assembly instance
    assembly_instance = doc.GetElement(assembly_instance_id)
    if not isinstance(assembly_instance, AssemblyInstance):
        raise ValueError("The provided ElementId is not an AssemblyInstance.")

    # 2️⃣ List to store views associated with the assembly
    associated_views = []

    # 3️⃣ Filter to collect all views in the document
    view_collector = FilteredElementCollector(doc).OfClass(View)

    # 4️⃣ Loop through the views and find those associated with the assembly instance
    for view in view_collector:
        if view.AssociatedAssemblyInstanceId == assembly_instance_id:
            associated_views.append(view.Id)

    return associated_views

# 🎣 Example usage
assembly_instance_id = ElementId(2694)  

# 🛒List the associated views
associated_views = get_assembly_views(doc, assembly_instance_id)

# 🎹 output the associated view IDs
OUT = ("Associated Views:", [viewId.IntegerValue for viewId in associated_views])

here is an example by assembly ID… you get the Ids of the created views…