patch visible (not hided) elements into a new ifc in Bonsai

edited January 9 in General
  • load a IFC into Bonsai
  • hide elements either by the use of the tree or by the use of Colour By Property and Select by Property and H-Button or some other workflow
  • How is it possible to use patch of all visible elements and save a new ifc out of them?

  • A temporary workaround could be to get all GUID from all visible elements. With a small code snippet this could be transfered to a query to be used in patch. The question here would be how to get all GUID from all visible elements.

cheers bernd

Comments

  • edited January 9

    There is a "Load from Memory" checkbox already on Patch GUI in Bonsai, but it uses all elements from the loaded ifc and not the visible ones.

  • Noone an idea ... How to get all GUID from all visible objects in Bonsai by python?

  • edited January 21

    not sure this is correct (just trying to guess here)
    visible object can be found with

    import bpy
    import ifcopenshell
    from bonsai import tool
    model = tool.Ifc.get()
    
    objlst = bpy.data.objects
    
    for obj in objlst:
        if obj.name.startswith("Ifc") and obj.visible_get():
            print(obj.name)
    

    which prints a list of Blender "turned on" objects in the model returning IfcClass/name, you can make a dictionary out of it or a list

    from there maybe you could use ifcopenshell.util.selector(model, query) that accepts name and type in it to narrow them down to valid IfcBuildingElement
    after that the GUID comes with element.id()
    sorry I am not much of an expert in python, just curious to see how this can be achieved

  • edited January 22

    Python programmer here.
    The best way is to create a new recipe with ifcpatch

    Have a look here:
    https://docs.ifcopenshell.org/ifcpatch.html
    and here
    https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.8.0/src/ifcpatch/ifcpatch/recipes
    This is the location on your system where you save new recipes: %AppData%\Blender Foundation\Blender\4.2\extensions\.local\lib\python3.11\site-packages\ifcpatch\recipes
    Restart blender to make them available :)

    theoryshawMassimo
Sign In or Register to comment.