I am trying to create a Dynamo graph that overrides the Color of some Revision Clouds in all views, including dependents.
I first created a list of the Revision Clouds I want to override, now I would like to create a list (of lists) that gives me the owner view and (if existent) it’s correspondent dependent views. As a beginner, I imagine I am missing something in the function “depen”, as the Output only Shows me one dependent view per owner (one of them should have 3 dependents). Could someone help me with that please? Cheers!
‘return’ will end your function and for loop. You’ll want to collect your dependent views on your temp list first, then return the view and temp list after the for loop.
If I may speculate, because I already provided solution with nodes and packages in other topic, I think what @bialmeida wan’t is to reach a working results with Python and learn a bit. Something what we all encourage here.
@bialmeida for somebody to test your script, provide the text version as well, not just screenshot because nobody is going to retype so much lines to help others. We are all working people after all .
I’m not at my pc, so I’ll check this one later out and see if I can help. Meanwhile if somebody has time te help now, feel free to do so.
I managed to create the list of lists I wanted (thanks @Kibar), and thought everything would be fine once I create a new list of Revision Clouds that replicates the revisions according to the amount of dependent views, so I can pair them and use the zip you recommended yesterday - for example:
Revision Cloud 3601952 appears only one time (no dependent views), Revision 3602394 appears 4 times (one owner and 3 dependents), so I create a new list that goes:
Revision 3601952
Revision 3602394
Revision 3602394
Revision 3602394
Revision 3602394
and so on
Thanks for the hint, I added the .dyn file here and hope it helps?
I am also open to other recomendations of course
Thank you very much!!
The last line takes every item of your list of views and counts it. Then it takes every item of your revision list and multiplies it by that count.
Tip! Never ever ever use drop down menus in your Script. So instead of node Categories use Category.ByName. You can read here why exactly it’s not a good idea and my simple solution to resolve it.
import clr
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# credits Kulkul https://forum.dynamobim.com/t/use-the-flatten-node-in-python-script/10363/3
def flatten(a, r=None):
if r is None:
r = []
for x in a:
if isinstance(x, list):
flatten(x, r)
else:
r.append(x)
return r
##################################################
# Erstellung einer Liste, die die Owner-Views enthält (ownerviews)
ownerviews = list()
def GetOwnerView(item):
return ownerviews.append(item.Document.GetElement(item.OwnerViewId))
revisions = UnwrapElement(IN[0])
for revision in revisions:
GetOwnerView(revision)
##################################################
# Erstellung einer Liste, die die entsprechenden Dependent-Views enthält
dependents = list()
def depen(view):
temp = list()
dependentIds = view.GetDependentViewIds()
for Id in dependentIds:
if Id is not None:
temp.append(doc.GetElement(Id))
else:
return list()
return temp
for x in range(len(ownerviews)):
owner1 = ownerviews[x]
dependents.append(depen(owner1))
##################################################
# Erstellung einer Liste, die die Owner-Views und Dependent-Views zusammenbringt
for x in range(len(ownerviews)):
dependents[x].append(ownerviews[x])
##################################################
# Erstellung einer Liste, die die Anzahl von Revisionswolken pro View enthält
countlist = list()
for x in dependents:
count = 0
for y in x:
count = count + 1
countlist.append(count)
revision = [[i]*len(k) for i, k in zip(revisions,dependents)]
OUT = flatten(dependents), flatten(revision)
Thank you SO much guys, that was incredibly helpful!
It’s a pitty it’s not possible to mark two answers as a solution, why is that so?
Thanks again both of you!!