Dear Colleagues, I am having problems again with my coding so I hope you can give some feedback regarding this issue.
I will explain what is the goal: I want to develop a script to place the elements in the right workset, but in my case we have some conditionals. My inputs are:
Workset Name = [w1,w2…wn] List with Unique worksets
Conditional = List[ c1,c2,…cn] List with Parameter or Names
Tipe of Conditional = List[cond1,cond2,…condn] List with True or False
Contains= List[prhase1,[phrase2.1,phrase2.2,phrase2.n],…phrasen] List that can contain sublist with phrases
Elements = [[e1.1,e1.2,…e1.n],[e2.1,e2.2,…e2.n]…[en.1,en.2,…en.n] List with sublist of elements already filter for the main category of the workset conditional
So for this phase, the only thing I need is for the evaluation to be carried out to know if the element should be in the workset or not. It is omitted if it should not be, or the list is empty. I want a structured list with worksets and elements that meet the condition.
At the moment, I have this, but it is not working for me; I am new to the definitions, so I would be looking for your support to see where I am making my mistake.
Thank you in advance for all the support you offer to the community.
This is the code and I left a dummy script to make easy the evaluation that they script works
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('DSCoreNodes')
import DSCore
from DSCore import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
Allcats=doc.Settings.Categories
# Place your code below this line
WNames = IN[0][0]
CondN=IN[0][1]
CondC=IN[0][2]
CondL=IN[0][3]
LCatE=IN[1]
#Contains Parameter
def ContainsPar(find, element, condition, values):
if find == "Family Name" and condition:
#val = element.Name
val = element
for value in values:
if val.Contains(value):
el = element
return val,el
#Family Name does not contain
elif find == "Family Name" and condition != True:
#val = element.Name
val = element
for value in values:
if val.Contains(value) == False:
el = element
return val,el
#By parameter contains
elif find != "Family Name" and condition:
val = element.LookupParameter(find).AsString()
for value in values:
if val.Contains(value):
el = element
return val,el
#By parameter does not contains
elif find != "Family Name" and condition is False:
val = element.LookupParameter(find).AsString()
for value in values:
if val.Contains(value) == False:
el = element
return val,el
else:
return None
newworks, newlist=[] ,[]
#trial = ContainsPar(CondN, LCatE, CondC, CondL)
for CatE,wnam,cdn,cdc,cdl in zip(LCatE,WNames,CondN,CondC,CondL):
for elem in CatE:
ev =ContainsPar(cdn, CatE, cdc, cdl)
if ev != None:
newworks.append(wnam)
newlist.append(ev)
# Assign your output to the OUT variable.
OUT = newworks, newlist
Test-Filter-Evaluation.dyn (14.5 KB)