New IFC facet-based selector syntax

13

Comments

  • Where can I find this filter in the latest release? I would like to filter by LoadBearing and EXISTING and make it visible in the 3D view.


  • I'm not fully understanding the correct syntax here.

  • @Coen said:
    I'm not fully understanding the correct syntax here.

    I tried Grouping and Filtering on my computer and I noticed some odd behavior:

    • Pset_WallCommon.Status = NEW works
    • Pset_WallCommon.Combustible with True throws an error

    • but if I use Pset_WallCommon.Combustible with 1 (instead of True) it works..

    • Pset_WallCommon.IsExternal does not return any selection with either True or 1
    • Same applies to Pset_WallCommon.LoadBearing

    it would be interesting to know the right way to do it, thanks

  • edited February 2024

    @steverugi said:

    • Pset_WallCommon.IsExternal does not return any selection with either True or 1
    • Same applies to Pset_WallCommon.LoadBearing

    For me these work with the input 1, true gives the error.

    Blender 3.6.8 BBIM 240222

    Coen
  • @Coen said:

    I'm not fully understanding the correct syntax here.

    I think you have to type "TRUE"

    Coensteverugi
  • I hope it's ok to piggyback onto this discussion. I have been trying out schedules and have been facing some difficulties.
    Here are my filters and CSV Attributes in BlenderBim:

    Here is how it looks in OpenOffice:

    Here is what it looks like when I use BBim to build the schedule into a SVG:

    The things I would like to solve are:
    1. Is it possible to replace the underscore with a space character? I tried {{value}}.replace("_", " ")
    2. Is there a BBim solution to get ElementType values to appear in place of the USERDEFINED value of PredefinedType
    3. In the ods file my column headings are bold, should they pass through to the SVG?
    4. In the ods file I wrapped my cells but this doesn't seem to be translating correctly. Is there a way to fix this in OpenOffice?
    5. Is there a way in BBim to apply rounding to a {{value}} that consists of multiple values?
    6. I can't get my storey names to appear, what am I doing wrong?
    7. Is there a BBim solution to not show the None values (or just show one)?

    theoryshawArv
  • Good questions. I think i only know the following...
    4. It's advisable to use opengost-b font when making your svg schedules. A lot of spacing, etc, is currently hardcoded assuming this font. If you use a different font, things can start looking weird.
    6. maybe try storey.Name?

  • Thanks @theoryshaw. I did first try storey.Name but that didn't work and I presumed so because I am initially pulling in types not instances.

  • @tim 2. Try predefined_type

    tim
  • edited March 2024

    @tim I see you're using Tag as the ID or Type Mark. I wanted to do that too, and seems to be the way to do it, but might want to read the following...

    tim
  • timtim
    edited March 2024

    Thanks @theoryshaw, looks like the 'correct' way is to use the name field then. If the Tag field is only used by external exporters, should it not be a read-only value in BlenderBIM, or maybe it shouldn’t be in the UI at all. Is there a use case for having it visible or editable?

  • Would it be possible to select all objects belonging to a bSDD classification such as https://search.bsdd.buildingsmart.org/uri/buildingsmart/ifc/4.3/class/IfcBuiltSystemLOADBEARING

  • @martin said:
    Would it be possible to select all objects belonging to a bSDD classification such as https://search.bsdd.buildingsmart.org/uri/buildingsmart/ifc/4.3/class/IfcBuiltSystemLOADBEARING

    Sure, it's ifcopenshell.util.selector.filter_elements(ifc_file, 'IfcTypeProduct, IfcProduct, classification="IfcBuiltSystemLOADBEARING"')

    Or from BBIM UI:

    steverugi
  • IfcFurniture, PredefinedType="CHAIR"
    This doesn't seem to work. Am i missing something?
    In this scenario, the instance is taking on the Type's PredefinedType.

  • edited April 2024

    I don't know if I understood correctly, but try IfcFurniture, query:predefined_type=CHAIR

    Remember to remove the equal sign here:

    Does that work?

    theoryshawsteverugi
  • edited April 2024

    yes, that works! Thanks @bruno_perdigao
    ...
    Intuitively, it seems like the other way should work too... since it's an 'Attribute'. ¯\_(ツ)_/¯

  • @theoryshaw said:
    yes, that works! Thanks @bruno_perdigao
    ...
    Intuitively, it seems like the other way should work too... since it's an 'Attribute'. ¯\_(ツ)_/¯

    makes sense, it should work both ways after this commit

    bruno_perdigaotheoryshaw
  • edited April 2024

    Hi @Andrej730

    @martin said:

    Or from BBIM UI:

    I am trying to implement RICSclassification (NRM1 and 2)

    how would I catch something like
    #105=IFCCLASSIFICATIONREFERENCE($,'1.1.3.1','Lowest floor construction',#66,$,$);

    or any other classified element of which I know the code (in this case '1.1.3.1'), or its description

    since the BoQ does not export classification (yet?) it would be useful to do it through spreadsheet
    thanks

    EDIT

    please disregard my request, I figured it out
    for those who are looking for the same:

    as selector for spreadsheet export to csv:
    classification.Name returns 'Lowest floor construction'
    classification.Identification returns '1.1.3.1'

    in Search use the "Classification" filter and apply the Identification code in the cell:

    cheers

  • @steverugi said:
    how would I catch something like
    #105=IFCCLASSIFICATIONREFERENCE($,'1.1.3.1','Lowest floor construction',#66,$,$);

    or any other classified element of which I know the code (in this case '1.1.3.1'), or its description

    "IfcClassificationReference, Description=description" or ""IfcClassificationReference, Identification=test_code"?

    steverugi
  • edited May 2024

    Hi @Andrej730

    please where in the UI you use the following?

    "IfcClassificationReference, Description=description" or ""IfcClassificationReference, Identification=test_code"?

    do you know what to use in a cost schedule as query? It would be very useful to select classified elements in a BoQ
    IfcSlab, classification="1.1.1.1.11" works in Grouping and Filtering > Search but when used in a cost schedule it does not return anything
    thanks

    EDIT

    for some reason IfcSlab, classification="1.1.1.1.11" works now in a .csv cost schedule to automate BoQ QTO extraction, I'm still curious to know the use case of IfcClassificationReference, Description.. though, cheers

  • edited May 2024

    I am faceing a problem ...

    ifcbimtester uses doublequotes to mark values ... https://github.com/IfcOpenShell/IfcOpenShell/blob/69c197c1a4f047791befbae11e890be64026b7e7/src/ifcbimtester/bimtester/features/steps/classification/en.py
    I started to use a query in ifcbimtester as value (which is very very cool :-)) I need to use double quotes ATM to mark it as a value. But if inside the query I need to quote something I can not use double quotes I would need to use a single quote, but single quotes do not work in the querries.

    The other way would be to switch in ifcbimtester to use single quotes for the values. Than the query would be in single quotes and I could use double quotes inside the query. But this is in the contrary to all ifcbimtester.

    Thus ... would it be possible to support single quotes inside the querys as well.

    cheers bernd

  • Couldn't you just escape the quotes?

  • edited May 2024

    like this ... ?

    from ifcopenshell.util import selector
    # query = "IfcWall, AllplanAttributes.Status=Neubau, material=Dämmung, Name='Dämmung eingelegt'"  # error
    query = "IfcWall, AllplanAttributes.Status=Neubau, material=Dämmung, Name=\"Dämmung eingelegt\""  # works
    eles = ifcopenshell.util.selector.filter_elements(ifcfile, query)
    

    works for the query. I will give it a try in ifcbimtester. But since ifcbimtester is human readable any IT-specific character does cut the peoples number who do understand the text into a half ;-)

    BTW: this query system is very very very cool. It replaces tons of lines of code I have made over years by a simple statement. :-)

  • edited May 2024

    @Moult said:
    Couldn't you just escape the quotes?

    no it does not work in ifcbimtester ... but nevermind ...

    features:

    Szenario: Layernames test
     #* All "{ifcos_query}" elements have a layer named "{layer_name}"
     * All "IfcColumn, AllplanAttributes.Status=Neubau, material=FertigelementBeton, Name=Stuetze" elements have a layer named "_HB_N_BTL_FB_Stuetze"
     * All "IfcWall, AllplanAttributes.Status=Neubau, material=\"Fertigelement Beton\", Name=Wandschicht" elements have a layer named "_HB_N_BTL_FB_Wand"
    

    works:

     All "IfcColumn, AllplanAttributes.Status=Neubau, material=FertigelementBeton, Name=Stuetze" elements have a layer named "_HB_N_BTL_FB_Stuetze" 162 eles, 0.68s
    

    does not work:

    All "IfcWall, AllplanAttributes.Status=Neubau, material=\"Fertigelement Beton\", Name=Wandschicht" elements have a layer named "_HB_N_BTL_FB_Wand" 162 eles, 0.01s
    
    File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\behave\model.py", line 1329, in run
    match.run(runner.context)
    File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\behave\matchers.py", line 98, in run
    self.func(context, *args, **kwargs)
    File "C:\Users\BHA\AppData\Roaming\FreeCAD\Mod\bimtester\code_bimtester\bimtester\features\steps\layer_and_style\en.py", line 40, in step_impl
    ifcos_query_has_following_layer_name(
    File "C:\Users\BHA\AppData\Roaming\FreeCAD\Mod\bimtester\code_bimtester\bimtester\features\steps\layer_and_style\en.py", line 152, in ifcos_query_has_following_layer_name
    target_elements = ifcopenshell.util.selector.filter_elements(IfcStore.file, target_ifcos_query)
    File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\ifcopenshell\util\selector.py", line 311, in filter_elements
    transformer.transform(filter_elements_grammar.parse(query))
    File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\lark.py", line 645, in parse
    return self.parser.parse(text, start=start, on_error=on_error)
    File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\parser_frontends.py", line 96, in parse
    return self.parser.parse(stream, chosen_start, **kw)
    File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\parsers\earley.py", line 266, in parse
    to_scan = self._parse(lexer, columns, to_scan, start_symbol)
    File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\parsers\xearley.py", line 146, in _parse
    to_scan = scan(i, to_scan)
    File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\parsers\xearley.py", line 119, in scan
    raise UnexpectedCharacters(stream, i, text_line, text_column, {item.expect.name for item in to_scan},
    lark.exceptions.UnexpectedCharacters: No terminal matches 'B' in the current parser context, at line 1 col 68
    
    Status=Neubau, material=\"Fertigelement Beton\", Name=Wandschicht
    ^
    Expected one of:
    * PLUS
    * COMMA
    
  • I haven't looked at the BIMTester codebase in ages and I have no idea what it supports or doesn't support anymore. Can you try printing to check exactly what behave is parsing and sending off to the filter_elements function? That can help narrow it down whether the problem is with behave and quotes, or BIMTester and quotes, or filter_elements itself.

  • The problem is in behave because the standard parse step matcher can not parse a " inside a step parameter which is marked by "{}" ...
    I found a (may be not smart, but working) work around which I will use ATM. Before sending the query to IfcOpenShell I replace ' by " like this ...

    from ifcopenshell.util import selector
    query = "IfcWall, AllplanAttributes.Status=Neubau, material=Dämmung, Name='Dämmung eingelegt'".replace("'",'"')  # works
    eles = ifcopenshell.util.selector.filter_elements(ifcfile, query)
    

    This way I do not need to change anything in ifcbimtester and do not need to investigate more ATM.

    cheers bernd

  • edited May 2024

    @steverugi said:
    I'm still curious to know the use case of IfcClassificationReference, Description.. though, cheers

    You can use it in scripts if you want to get all matching IfcClassificationReferences or in Spreadsheet Export if you want to export list of all used classification references with certain description (though you won't be able import it back, I think, as importing .csv typically requires guid).

    If you want to get list of all elements that has a refernce with some description then I don't think it's possible - when you do IfcSlab, classification="1.1.1.1.11" it checks all references Name "1.1.1.1.11" (so you can use the same syntax to match by reference name) and then it checks references' Identification but never checks Description.

    steverugi
  • edited June 2024

    I have problems on quantities ... I am not able to use any regex or a * to filter multiple quantity values or alle object with the quantity attached

    cheers bernd

    # works ...
    from ifcopenshell.util import selector
    query = "IfcWall"
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    query = "IfcWall, material=Ortbeton"
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    query = "IfcWall, material=Backstein, Qto_WallBaseQuantities.Dicke='0.175'".replace("'",'"')
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    query = 'IfcWall, material=Ortbeton, Qto_WallBaseQuantities.Dicke="0.28"'
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    query = "IfcWall, AllplanAttributes.Allright_Bauteil_ID=/\d+/"
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    query = "IfcWall, AllplanAttributes.Allright_Bauteil_ID=/0*/"
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    query = "IfcWall, AllplanAttributes.Allright_Bauteil_ID=/[a-zA-Z_0-9]+/"
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    # none of them works
    query = "IfcWall, material=Ortbeton, Qto_WallBaseQuantities.Dicke=/\d+\.\d+/"
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    query = "IfcWall, material=Ortbeton, Qto_WallBaseQuantities.Dicke=/[0-9]\.[0-9]{3}/"
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    query = "IfcWall, Qto_WallBaseQuantities.Dicke=/\d+/"
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    query = "IfcWall, Qto_WallBaseQuantities.Dicke=/[a-zA-Z_0-9]+/"
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    
    >>> # works ...
    >>> from ifcopenshell.util import selector
    >>> query = "IfcWall"
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    61
    >>> query = "IfcWall, material=Ortbeton"
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    25
    >>> query = "IfcWall, material=Backstein, Qto_WallBaseQuantities.Dicke='0.175'".replace("'",'"')
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    36
    >>> query = 'IfcWall, material=Ortbeton, Qto_WallBaseQuantities.Dicke="0.28"'
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    25
    >>> query = "IfcWall, AllplanAttributes.Allright_Bauteil_ID=/\d+/"
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    61
    >>> query = "IfcWall, AllplanAttributes.Allright_Bauteil_ID=/0*/"
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    61
    >>> query = "IfcWall, AllplanAttributes.Allright_Bauteil_ID=/[a-zA-Z_0-9]+/"
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    61
    >>> 
    >>> 
    >>> # none of them works
    >>> query = "IfcWall, material=Ortbeton, Qto_WallBaseQuantities.Dicke=/\d+\.\d+/"
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    Traceback (most recent call last):
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 124, in _call_userfunc
        return f(children)
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\ifcopenshell\util\selector.py", line 574, in property
        self.elements = set(filter(filter_function, self.elements))
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\ifcopenshell\util\selector.py", line 553, in filter_function
        return self.compare(element_value, comparison, value)
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\ifcopenshell\util\selector.py", line 732, in compare
        result = bool(value.match(element_value)) if element_value is not None else False
    TypeError: expected string or bytes-like object
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\ifcopenshell\util\selector.py", line 311, in filter_elements
        transformer.transform(filter_elements_grammar.parse(query))
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 161, in transform
        return self._transform_tree(tree)
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 156, in _transform_tree
        children = list(self._transform_children(tree.children))
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 146, in _transform_children
        res = self._transform_tree(c)
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 156, in _transform_tree
        children = list(self._transform_children(tree.children))
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 146, in _transform_children
        res = self._transform_tree(c)
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 156, in _transform_tree
        children = list(self._transform_children(tree.children))
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 146, in _transform_children
        res = self._transform_tree(c)
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 156, in _transform_tree
        children = list(self._transform_children(tree.children))
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 146, in _transform_children
        res = self._transform_tree(c)
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 157, in _transform_tree
        return self._call_userfunc(tree, children)
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\lark\visitors.py", line 128, in _call_userfunc
        raise VisitError(tree.data, tree, e)
    lark.exceptions.VisitError: Error trying to process rule "property":
    
    expected string or bytes-like object
    >>> 
    

    attached the file ...

  • Isn't that because you're using regex on non-strings?

Sign In or Register to comment.