New IFC facet-based selector syntax

124»

Comments

  • @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?
  • edited June 2024

    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
     >>> 
    
  • edited June 2024

    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
    
    >>> 
    
  • edited June 2024

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

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

  • Just got the model seen in the screen from an landscape architect. 180 MB but probably 95% data volumes are trees which I do not need at all ... Let BBIM help myself to get something to easily work with ...

    First idea:
    Open the file in BBIM and delete the trees works fine, but takes two hours on my machanine. But BBIM did not crash :-) But there must be a better way ... Actually there is ...

    Second idea, use the filter and IfcPatch
    Start by finding the correct filter by python ...

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

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

    Since it seams to work fine, use IfcPatch tool from BBIM Gui with the query from above:
    IfcBuildingElement, Name!=/^Platane/, Name!=/^Bush/, Name!=/^Willow/, Name!=/^Black_Maple/, Name!=/^Nordmann/, Name!=/^Elm_Tree/, Name!=/^Chestnut_Tree/

    takes just 10 minutes all together and results in a ifc of around 11.4 MB ... :-) More than 10 times faster than open the file in BBBIM Gui, deleting the elems and save the file and much more robust.

  • edited September 2024

    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/



    theoryshawMassimoAce
  • 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
    >>> 
    
    MassimoJohnemiliotasso
  • edited September 2024

    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),$);

  • edited September 2024

    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'),$);

  • edited September 2024

    solved one of the two problems ...

    @bernd said:
    A property name does have a Space inside. I am not able to filterfor this property values ...

    query = "IfcWall, Architekt.'Tragendes Bauteil'=/^FALSE/"
    

    it has to be
    query = 'IfcWall, Allreal."Tragendes Bauteil"=/^FALSE/'

    steverugitheoryshawJohn
  • edited September 2024

    noone out here a idea if it is not implemented or if I do some mistake ...

    @bernd said:
    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),$);

  • @theoryshaw said:
    Maybe...

    thanks, I meant to add yours to my query examples but, what is a practical use of layer in Bonsai? the same as in DWG? cheers

  • Yes, as i understand it, it's kinda like that. I don't use it, however.

    steverugi
  • Good evening. How do I exclude IfcAnnotation[GRID] from my drawings when I create them. All efforts are not yielding results.
    Thank you.

  • edited September 2024

    Exclude: IfcAnnotation, ObjectType = GRID

    Owura_qu
  • @theoryshaw said:
    Exclude: IfcAnnotation, ObjectType = GRID

    Thank you very much.

Sign In or Register to comment.