execute_ifc_code
Execute Python code to query, read, and write IFC entities and properties with IfcOpenShell/Bonsai APIs. Pre-injected namespace simplifies BIM data operations.
Instructions
[EDIT] PREFERRED code execution tool. Runs IfcOpenShell / Bonsai API code with a pre-injected IFC namespace. bpy access is BLOCKED; use execute_blender_code only when you genuinely need Blender operations (viewport, rendering, object transforms). Pre-injected variables: ifc (the loaded IFC file or None), ifcopenshell, ifc_api (ifcopenshell.api), element_util (ifcopenshell.util.element), tool (bonsai.tool). Pre-injected helper functions: get_ifc_file() (loaded IFC file or raises), get_default_container() (active spatial container), save_and_load_ifc(path=None) (save the project and reload it; call this after IFC edits to make them visible in the viewport, since edits do NOT appear until the project is reloaded). Use this for: querying IFC entities, reading/writing properties, traversing the IFC model, calling ifcopenshell.api operations, and any BIM data work.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python source using IfcOpenShell/Bonsai APIs. bpy imports are rejected. |