OSArch Community

New IFC facet-based selector syntax

  1. T

    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.

  2. B

    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?

  3. T

    yes, that works! Thanks @bruno_perdigao

    ...

    Intuitively, it seems like the other way should work too... since it's an 'Attribute'. ¯\_(ツ)_/¯

  4. A

    @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

  5. S

    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

  6. A

    @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"?

  7. S

    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

  8. B

    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

  9. M

    Couldn't you just escape the quotes?

  10. B

    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. :-)

  11. B

    @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
  12. M

    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.

  13. B

    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

  14. A

    @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.

  15. B

    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 ...

  16. M

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

  17. B

    @Moult said:

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

    That explains a lot.

    #97=IFCQUANTITYLENGTH('Dicke',$,$,0.28);

    Than I need to ask the question different.

    • How specify I non string values if it is not the exact value I seacht for?

    • How do I find all elements with a special quantity assigned?

    • How do I find all elements with a special quantity with a special value. lets say in may case >= 0.20?

  18. B

    ahh ... found it ... it's so easy ... I have no idea why I just not tried what I do in Python all time. Probably the need of the quotes confused me at all.

    query = 'IfcWall, Qto_WallBaseQuantities.Dicke>=0'
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = 'IfcWall, Qto_WallBaseQuantities.Dicke<"0.28"'
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = 'IfcWall, Qto_WallBaseQuantities.Dicke>="0.28"'
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    
    
    
    
     >>> 
    
     >>> query = 'IfcWall, Qto_WallBaseQuantities.Dicke>=0'
    
     >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
     61
    
     >>> query = 'IfcWall, Qto_WallBaseQuantities.Dicke<"0.28"'
    
     >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
     36
    
     >>> query = 'IfcWall, Qto_WallBaseQuantities.Dicke>="0.28"'
    
     >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
     25
    
     >>> 
  19. B

    next filter problem ...

    file from this post https://community.osarch.org/discussion/comment/20854/#Comment_20854

    # works great :-)
    
    from ifcopenshell.util import selector
    
    query = "IfcWall, FBJ_Properties.HB_Std_Gewerk=Betonarbeiten"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = "IfcWall, FBJ_Properties.HB_Std_Gewerk=Mauerarbeiten"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))

    but use the ! does not seam to work with properties ...

    # works not ... 
    
    query = "IfcWall, ! FBJ_Properties.HB_Std_Gewerk=Betonarbeiten"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))

    Error ...

    >>> query = "IfcWall, ! FBJ_Properties.HB_Std_Gewerk=Betonarbeiten"
    
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    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\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 'F' in the current parser context, at line 1 col 12
    
    
    
    IfcWall, ! FBJ_Properties.HB_Std_Gewerk=Betonarbeit
    
               ^
    
    Expected one of: 
    
        * __ANON_0
    
        * __ANON_3
    
    
    
    >>> 
  20. B

    once again ... just use Python relational operator ...

    # works great :-)
    
    from ifcopenshell.util import selector
    
    query = "IfcWall, FBJ_Properties.HB_Std_Gewerk=Betonarbeiten"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = "IfcWall, FBJ_Properties.HB_Std_Gewerk=Mauerarbeiten"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = "IfcWall, FBJ_Properties.HB_Std_Gewerk!=Betonarbeiten"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = "IfcWall, FBJ_Properties.HB_Std_Gewerk!=Mauerarbeiten"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    
    
    
    >>> 
    
    >>> query = "IfcWall, FBJ_Properties.HB_Std_Gewerk=Betonarbeiten"
    
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    32
    
    >>> query = "IfcWall, FBJ_Properties.HB_Std_Gewerk=Mauerarbeiten"
    
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    29
    
    >>> query = "IfcWall, FBJ_Properties.HB_Std_Gewerk!=Betonarbeiten"
    
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    29
    
    >>> query = "IfcWall, FBJ_Properties.HB_Std_Gewerk!=Mauerarbeiten"
    
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    32
    
    >>> 

    sometimes it needs a post to solve the problem myself, I have no idea why , sorry for the noise ...

  21. J

    @bernd it's far from noise, it's a really helpful guide for people like me trying to learn and understand. More, please.

  22. B

    I got a ifc from a landscape architekt of 180 MB containing probably 95 % data in trees which I do not need at all. The idea was to use BBIM to create a new ifc without the trees. Means filter all element except all the trees ... This was what I came up with ...

    from ifcopenshell.util import selector
    
    query = "IfcBuildingElement"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = "IfcBuildingElement, Name!=/^Platane/, Name!=/^Bush/, Name!=/^Willow/, Name!=/^Black_Maple/, Name!=/^Nordmann/, Name!=/^Elm_Tree/, Name!=/^Chestnut_Tree/"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    
    
    
    >>> 
    
    >>> from ifcopenshell.util import selector
    
    >>> query = "IfcBuildingElement"
    
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    724
    
    >>> query = "IfcBuildingElement, Name!=/^Platane/, Name!=/^Bush/, Name!=/^Willow/, Name!=/^Black_Maple/, Name!=/^Nordmann/, Name!=/^Elm_Tree/, Name!=/^Chestnut_Tree/"
    
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    576
    
    >>> 

    In BBGui run IFCPatch by the use of the filter from above and get a ifc file of 11.4 MB ... :-)

    IfcBuildingElement, Name!=/^Platane/, Name!=/^Bush/, Name!=/^Willow/, Name!=/^Black_Maple/, Name!=/^Nordmann/, Name!=/^Elm_Tree/, Name!=/^Chestnut_Tree/

  23. B

    found a even simpler way to filter. It works inside one regex ...

    from ifcopenshell.util import selector
    
    query = "IfcBuildingElement"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = "IfcBuildingElement, Name!=/^Platane/, Name!=/^Bush/, Name!=/^Willow/, Name!=/^Black_Maple/, Name!=/^Nordmann/, Name!=/^Elm_Tree/, Name!=/^Chestnut_Tree/"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = "IfcBuildingElement, Name!=/^Platane|^Bush|^Willow|^Black_Maple|^Nordmann|^Elm_Tree|^Chestnut_Tree/"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))

    results in:

    >>> 
    
    >>> from ifcopenshell.util import selector
    
    >>> query = "IfcBuildingElement"
    
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    724
    
    >>> query = "IfcBuildingElement, Name!=/^Platane/, Name!=/^Bush/, Name!=/^Willow/, Name!=/^Black_Maple/, Name!=/^Nordmann/, Name!=/^Elm_Tree/, Name!=/^Chestnut_Tree/"
    
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    576
    
    >>> query = "IfcBuildingElement, Name!=/^Platane|^Bush|^Willow|^Black_Maple|^Nordmann|^Elm_Tree|^Chestnut_Tree/"
    
    >>> len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    576
    
    >>> 
  24. B

    next problem to solve ...

    "material" filters Materials, "Name" filters by Name ...

    What do I need to filter Layer ? I tried "Layer" and "layer" but both did not return something reasonable ...

    from IFC ...

    #113754=IFCPRESENTATIONLAYERASSIGNMENT('115 Liftanlagen.002',$,(#25008,#25402,#25403,#25404,#25405,#25406,#25407),$);

  25. B

    another one ...

    A property name does have a Space inside. I am not able to filterfor this property values ... Nothing of this works? BTW (False is really a String in this IFC ... bang ... )

    from ifcopenshell.util import selector
    
    query = "IfcWall, Architekt.Tragendes Bauteil=/^FALSE/"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = "IfcWall, Architekt.'Tragendes Bauteil'=/^FALSE/"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))
    
    query = "IfcWall, 'Architekt.Tragendes Bauteil'=/^FALSE/"
    
    len(ifcopenshell.util.selector.filter_elements(ifcfile, query))

    gives an Error in all three cases ...

    from IFC ...

    #2833771=IFCPROPERTYSINGLEVALUE('Tragendes Bauteil',$,IFCLABEL('FALSE'),$);

  1. Page 1
  2. 2
  3. 3
  4. 4
  5. 5

Login or Register to reply.