Hello,
I managed to make a script that select rebar based on an parameter and it’s value. The problem that I have is that for some reason I can’t select rebar based on the Bar Diameter parameter. I input same value into Model parameter and it worked well. can someone know way this happens?
Hello, hope this can help you
as I don’t know how to code in the best way (it’s a fact), I put a collection with 3 possibilities of diameter
import clr
import sys
import System
from System import Array
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
#######OK NOW YOU CAN TRY TO CODE########
collec_rebar=FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rebar).WhereElementIsNotElementType().ToElements()
bref=IN[0]
L_col_0=[]
L_col_1=[]
L_col_2=[]
essai=[]
for i in collec_rebar:
if i.get_Parameter(BuiltInParameter.REBAR_BAR_DIAMETER).AsDouble()*0.3048*1000==bref[0]:
L_col_0.append(i)
else:
pass
for i in collec_rebar:
if i.get_Parameter(BuiltInParameter.REBAR_BAR_DIAMETER).AsDouble()*0.3048*1000==bref[1]:
L_col_1.append(i)
else:
pass
for i in collec_rebar:
if i.get_Parameter(BuiltInParameter.REBAR_BAR_DIAMETER).AsDouble()*0.3048*1000==bref[2]:
L_col_2.append(i)
else:
pass
#I don't know how to use filters
pvp = ParameterValueProvider(ElementId(BuiltInParameter.REBAR_BAR_DIAMETER))
Eval=FilterNumericEquals()
rule=FilterIntegerRule(pvp,Eval,6/304.8)
filter=ElementParameterFilter(rule)
col1=FilteredElementCollector(doc).WherePasses(filter).WhereElementIsNotElementType().ToElements()
OUT = L_col_0,L_col_1,L_col_2,col1
Cordially
christian.stan
Thank you christian.stan,
Your code works but i don’t know how to integrate it into my scrip. Upon a little research I found that the problem it is with == node, it report all value as false. Is there something else with which I could change that nod?
Hello, as I had seen a python node at the end of your script, I thought you could modify my (wobbly) coding,
this overrides all of your nodes but with a single managed parameter
I’d lean towards a Type ID comparison, but I’m not sure what I’m saying
sorry for not being able to do better at this stage
Cordially
christian.stan
Hello,
That code at the end is only to low the script to highlight the bar that correspond to the search criteria. Until I found a solution for this I will use model parameter to search for bar diameter. The other option I have is to change colour of bar in context.