Python - Element Parameter Filter - Duct Length

Hi,

I’m having issues with the below collector as it doesn’t select the ducts with 1400 lengths (yes they are in the model). Any advice is appreciated just starting out on python. Aim is to collect ducts with 1400 lengths.

from Autodesk.Revit.DB import *

doc = __revit__.ActiveUIDocument.Document

uidoc = __revit__.ActiveUIDocument

#Provider

pvp = ParameterValueProvider(ElementId(BuiltInParameter.CURVE_ELEM_LENGTH))

#Evaluator

fnrv = FilterNumericEquals()

#Filter ducts that are 1400 in length

ruleValue = 1400

#Rule

fRule = FilterDoubleRule(pvp, fnrv, ruleValue, 1E-6)

#Parameter filter to pass into WherePasses Collctor

ParamFilter = ElementParameterFilter(fRule)

duct = FilteredElementCollector(doc) \

        .WherePasses(ParamFilter) \

        .ToElementIds()

uidoc.Selection.SetElementIds(duct)

hi @Allan.M,

can you share a sample file?

What’s the error say?
My first guess is maybe you need to start with some lists then feed the info in.

Hello @Allan.M

1/ it’s not the good template for Python in Dynamo, you need to read this

2/ What is the unit of length of 1400?

1 Like

Sorry I should have specified, this is being done through a Python shell in revit not Dynamo, so no need for IN[0] lists. The collector should collect all built in parameters of CURVE_ELEM_LENGTH then filter the ones with 1400 value.

There are no errors when I run the code but it doesn’t collect any elements so just seeing if anyone can see where I have gone wrong or missed something.

1400 is mm

Is this pyrevit not Dynamo?

Reading the document and came across the Units sections where the Length is actually shown in feet within Revit. Once I converted the 1400mm to feet this worked fine

Was more just help with python code