Cross-referencing elements with python


#1

This is a really basic python question, but I don’t know much python, I just copy and past code bits.

I am trying to determine if elements are visible in views. I have a lovely python script I nabbed from a post by Jostein Olsen that does it for the active view. I wish to send a list of views to it and have it spit out the results in sublists by view ([0]true/fales for each element in view 1, [1]true/fales for each element in view 2, etc…). I have hacked it together to run the whole thing as a giant string, which i could technically do some list multiplication in dynamo to sort, but it would be much better if I could get it to spit out as sublists from the script. I tried an addition “for” but I am guessing I need a “while” with an index track (or there may be a more elegant way)? Any help would be appreciated. Thanks.

import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
views = UnwrapElement(IN[1])
elements = UnwrapElement(IN[0])
listen = []
vlisten = []

for view in views:
for element in elements:
listen.append(element.IsHidden(view))
vlisten.append(listen)

OUT = vlisten

 


#2
import clr
 
 clr.AddReference("RevitAPI")
 import Autodesk
 from Autodesk.Revit.DB import *
 
 views = UnwrapElement(IN[1])
 elements = UnwrapElement(IN[0])
 
 listen = []
 for view in views:
     vlisten = []
     for element in elements:
         vlisten.append(element.IsHidden(view))
     listen.append(vlisten)
 
 OUT = listen

#3

Thanks