Skip to content

[Query]: would you add extra detail to filteredElementCollectorByParameter.py for additional rules and evaluators or see those as separate ? #3

Closed

Description

@adambear82

for example

# We then set up an empty instance of a Filter Numeric Equals to test against a set value (In this case - whether or not the Element has the box ticked for 'Enable Analytical Model'
evaluator = FilterNumericEquals()
# After we have the empty instance set up as our evaluator, we run a Filter Integer Rule that checks the chosen parameter (Enable Anyalytical Model), runs against the evaluator (Does this Number equal) and our value (1 which correlates to the tick inside of our yes/no tickbox)
rule = FilterIntegerRule( provider, evaluator, 1 )

an evaluator for greater than
evaluator = FilterNumericGreater()
which you could also use not for less than

an evaluator for string contains
evaluator = FilterStringContains()

an evaluator for strings equals
evaluator = FilterStringEquals()

a rule for strings
rule = FilterStringRule(provider, evaluator, test, False)

a rule for doubles
rule = FilterDoubleRule(provider, evaluator, test, 10**-3)

a rule for element ids
rule = FilterElementIdRule(provider, evaluator, test)

might also be helpful to refer to revitapidocs.com when trying to figure out what the param is

# Here we use the Built In Parameter method to choose the parameter (yes/no tickbox) of 'Enable Analytical Model' across all Elements inside of the Revit Document
param = BuiltInParameter.STRUCTURAL_ANALYTICAL_MODEL

Activity

  1. changed the title [-][Query]: would you add extra detail to filteredElementCollectorByParameter.py for additional rules and evaluators or see those as seperate[/-] [+][Query]: would you add extra detail to filteredElementCollectorByParameter.py for additional rules and evaluators or see those as separate ?[/+] on Jul 18, 2018
  2. Amoursol commented on Jul 18, 2018

    @Amoursol
    Owner

    This particular example is supposed to be able to be 'ran' simply through a copy and paste into a Python node. I'm torn as to the format for your suggestion and welcome any thoughts.

  3. adambear82 commented on Jul 18, 2018

    @adambear82
    CollaboratorAuthor

    I wondered if you might add some more #comments which show a few options, or alternatively you could create lots of different *.py files for different combinations of filters, rules, evaluators

    for my own purposes I didn't like having lots of separate files as there could be a lot of combinations of filters, rules, evaluators, so I wrote an example that did all sorts of things but with lots of commenting out

    '''
    exploration of the filtered element collector (fec)
    
    http://thebuildingcoder.typepad.com/blog/2010/06/parameter-filter.html
    https://forum.dynamobim.com/t/python-custom-rules-for-filteredelementcollector/21135/2?u=adam_bear1
    http://www.revitapidocs.com/2018.1/fb011c91-be7e-f737-28c7-3f1e1917a0e0.htm
    
    '''
    
    #------------------------------------------
    #boilerplate
    #------------------------------------------
    
    import clr
    clr.AddReference('RevitAPI')
    from Autodesk.Revit.DB import *
    import Autodesk
    
    clr.AddReference('RevitServices')
    from RevitServices.Persistence import DocumentManager
    from RevitServices.Transactions import TransactionManager
    
    doc = DocumentManager.Instance.CurrentDBDocument
    fec = FilteredElementCollector(doc)
    
    #------------------------------------------
    #useful list of bip to copy paste from revitapidocs.com
    #------------------------------------------
    
    #StringValues
    'ALL_MODEL_DESCRIPTION'
    'ALL_MODEL_MARK'
    'ALL_MODEL_INSTANCE_COMMENTS'
    'ALL_MODEL_TYPE_COMMENTS'
    
    #ElementId
    'ID_PARAM'
    
    #Integers
    'WALL_BOTTOM_IS_ATTACHED'
    'WALL_TOP_IS_ATTACHED'
    'WALL_ATTR_ROOM_BOUNDING'
    'RELATED_TO_MASS'
    'WALL_STRUCTURAL_SIGNIFICANT'
    'STRUCTURAL_ANALYTICAL_MODEL'
    
    #Doubles
    'ALL_MODEL_COST'
    
    enum = 'WALL_STRUCTURAL_SIGNIFICANT'
    
    #------------------------------------------
    #define myclass, bip, provider
    #------------------------------------------
    
    myclass = Wall
    #bip = BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT
    bip = eval('BuiltInParameter.' + enum)
    provider = ParameterValueProvider(ElementId(bip))
    
    #------------------------------------------
    #evaluate strings, elem id, integer, doubles
    #------------------------------------------
    
    #evaluate string values
    #test = 'aaa'
    #evaluator = FilterStringContains()
    #evaluator = FilterStringEquals()
    #rule = FilterStringRule(provider, evaluator, test, False)
    
    #evaluate element id
    #evaluator = FilterNumericEquals()
    #evaluator = FilterNumericGreater()
    #test = ElementId(0)
    #rule = FilterElementIdRule(provider, evaluator, test)
    
    #evaluate integer values
    test = 1
    evaluator = FilterNumericEquals()
    #evaluator = FilterNumericGreater()
    rule = FilterIntegerRule(provider, evaluator, test)
    
    #evaluate double values
    #test = 5.55
    #evaluator = FilterNumericEquals()
    #evaluator = FilterNumericGreater()
    #rule = FilterDoubleRule(provider, evaluator, test, 10**-3)
    
    #------------------------------------------
    #fec of class passing filter to elements
    #------------------------------------------
    
    filter = ElementParameterFilter(rule)
    elems = fec.OfClass(myclass).WherePasses(filter).ToElements()
    
    #------------------------------------------
    #output
    #------------------------------------------
    
    OUT = elems
    
  4. Amoursol commented on Jul 20, 2018

    @Amoursol
    Owner

    I think it useful to have my example as a 'run and done' - then another uploaded as 'mix and match' version! Feel free to create a Pull Request for such!

  5. added a commit that references this issue on Jul 24, 2018
  6. added 2 commits that reference this issue on Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions