[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7FA6785NVPK7PV17NXKYPTC":3,"skill-same:01M7FA6785NVPK7PV17NXKYPTC":63},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":13,"repositoryHtmlUrl":32,"repositoryHomepageUrl":6,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":34,"install":35,"resources":48},"01M7FA6785NVPK7PV17NXKYPTC","bonsai-core-architecture",null,"Use when developing Bonsai (formerly BlenderBIM) extensions, scripting BIM workflows in Blender, or understanding the Bonsai addon architecture. Prevents the common mistake of using ifcopenshell.open() to access the model instead of tool.Ifc.get() which gives the live Bonsai IFC file. Covers native IFC workflow, bpy.ops.bim.* operators, BIM property panels, and the relationship between Blender objects and IFC entities. Keywords: Bonsai, BlenderBIM, tool.Ifc.get(), bpy.ops.bim, native IFC, addon architecture, IFC-backed properties, BIM authoring, how does Bonsai work, Bonsai internals, Bonsai API.","lagzgabrielmuller-dot\u002Fkit-ingenieria-3d","lagzgabrielmuller-dot","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F333339260?v=4","01M7F985KYC0XB2XZ97B5YWH4C","01M7F985MHK8N2NVE4VAR5WBWS",0,"MIT","https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fblender-bim-sverchok\u002Fskills\u002Fbonsai\u002Fcore\u002Fbonsai-core-architecture\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: bonsai-core-architecture\ndescription: >\n  Use when developing Bonsai (formerly BlenderBIM) extensions, scripting BIM workflows in\n  Blender, or understanding the Bonsai addon architecture. Prevents the common mistake of\n  using ifcopenshell.open() to access the model instead of tool.Ifc.get() which gives the\n  live Bonsai IFC file. Covers native IFC workflow, bpy.ops.bim.* operators, BIM property\n  panels, and the relationship between Blender objects and IFC entities.\n  Keywords: Bonsai, BlenderBIM, tool.Ifc.get(), bpy.ops.bim, native IFC, addon architecture, IFC-backed properties, BIM authoring, how does Bonsai work, Bonsai internals, Bonsai API.\nversion: 'Bonsai v0.8.4 | Minimum Blender: 4.2.0 | Python 3.11'\nlicense: MIT\ncompatibility: \"Designed for Claude Code. Requires Blender 4.2.0+ with Bonsai v0.8.4+ and Python 3.11.\"\nmetadata:\n  author: OpenAEC-Foundation\n  version: \"1.0\"\n---\n\n# Bonsai Core Architecture\n\n> **Version**: Bonsai v0.8.4 | Blender 4.2.0+ | Python 3.11\n> **Module path**: `bonsai.*` — NEVER `blenderbim.*`\n> **Repository**: `IfcOpenShell\u002FIfcOpenShell` monorepo → `src\u002Fbonsai\u002F`\n\n## Critical Warnings\n\n1. **ALWAYS** use `bonsai.*` imports. NEVER use `blenderbim.*` — renamed in 2024 (v0.8.0+).\n2. **ALWAYS** check `IfcStore.get_file()` for `None` before any IFC operation.\n3. **NEVER** describe Bonsai workflow as \"import\u002Fexport\". The IFC file IS the document.\n4. **ALWAYS** run Bonsai scripts via `blender --python`. NEVER import `bonsai.*` from system Python.\n5. **ALWAYS** call `bpy.ops.bim.edit_object_placement()` after direct matrix\u002Flocation changes.\n6. **ALWAYS** use `ifcopenshell.api.run()` for IFC mutations, NEVER modify entity attributes directly.\n7. **NEVER** use `void.add_opening()` — use `feature.add_feature()` (changed in v0.8.0+).\n\n## Three-Layer Architecture\n\n```\n+-----------------------------------------------------+\n|  DELIVERY LAYER  — bim\u002Fmodule\u002F                       |\n|  Blender UI: operators, properties, panels, gizmos   |\n+-----------------------------------------------------+\n|  DOMAIN LAYER   — core\u002F + tool\u002F                      |\n|  Abstract use-case logic (core) + concrete impls     |\n|  (tool), injected via @interface contract             |\n+-----------------------------------------------------+\n|  DATA LAYER     — IfcStore + IFC in-memory graph     |\n|  Live ifcopenshell.file instance, id_map, guid_map   |\n+-----------------------------------------------------+\n```\n\n### Layer Rules\n\n| Layer | Location | Imports `bpy`? | Imports `ifcopenshell`? | Responsibility |\n|-------|----------|---------------|------------------------|----------------|\n| Delivery | `bim\u002Fmodule\u002F\u003Cname>\u002F` | YES | NO (via tool) | Blender UI, operators, panels |\n| Core | `core\u002F\u003Cname>.py` | NEVER | Via injected tool | Abstract use-case logic |\n| Tool | `tool\u002F\u003Cname>.py` | YES | YES | Concrete Blender + IFC operations |\n\n**Key principle**: Core NEVER imports `bpy`. All Blender-specific code lives in Tool implementations. This keeps business logic independently testable.\n\n## Module Structure Pattern\n\nEvery functional area follows a three-part split:\n\n| Sub-layer | Location | Purpose |\n|-----------|----------|---------|\n| UI (delivery) | `bim\u002Fmodule\u002F\u003Cname>\u002Fui.py`, `operator.py`, `prop.py` | Panels, operators, properties |\n| Core (abstract) | `core\u002F\u003Cname>.py` | Use-case flow, no Blender imports |\n| Tool (concrete) | `tool\u002F\u003Cname>.py` | Blender + IFC implementation |\n\n### Module File Structure\n\n| File | Purpose |\n|------|---------|\n| `__init__.py` | Package init |\n| `operator.py` | `bpy.types.Operator` subclasses (`bpy.ops.bim.*`) |\n| `prop.py` | `bpy.types.PropertyGroup` subclasses |\n| `ui.py` | Panel `draw()` methods |\n| `data.py` | Cached\u002Fcomputed UI data (refresh patterns) |\n| `decorator.py` | `bpy.types.SpaceView3D` draw callbacks (overlays) |\n| `gizmo.py` | `bpy.types.Gizmo` \u002F `GizmoGroup` subclasses |\n\n### Registered Modules (~51-56)\n\nBonsai registers approximately 51-56 functional modules, each corresponding to an IFC domain area:\n\n```\naggregate    alignment    attribute    bcf         boundary\nbrick        bsdd         cad          clash       classification\nconstraint   context      cost         covering    csv\ndebug        demo         diff         document    drawing\nfm           geometry     georeference gis         ifcgit\nlayer        library      material     nest        owner\npatch        profile      project      pset        pset_template\nqto          resource     search       sequence    spatial\nstructural   style        system       tester      type\nunit         void         web\n```\n\n### Demo Module: Reference Implementation\n\nThe `demo` module (`bim\u002Fmodule\u002Fdemo\u002F`) is a heavily commented reference implementation for new contributors. It demonstrates the full module pattern including all optional files. Enable it in `bonsai\u002Fbim\u002F__init__.py`.\n\n## The `@interface` Decorator Pattern\n\n`core\u002Ftool.py` defines tool interfaces using the `@interface` decorator — a design-by-contract enforcement mechanism:\n\n```python\n# bonsai\u002Fcore\u002Ftool.py (simplified)\n@interface\nclass Ifc:\n    def get(self): ...          # Returns ifcopenshell.file or None\n    def set(self, ifc): ...     # Sets active IFC file\n    def run(self, command, **kwargs): ...  # Runs ifcopenshell.api command\n    def get_entity(self, obj): ...        # Blender obj -> IFC entity\n    def get_object(self, element): ...    # IFC entity -> Blender obj\n    def link(self, element, obj): ...     # Bidirectional link\n\n@interface\nclass Spatial:\n    def assign_container(self, element, structure): ...\n```\n\nConcrete implementations live in `tool\u002Fifc.py`, `tool\u002Fspatial.py`, etc. Operators import them as `tool.Ifc`, `tool.Spatial`.\n\n## Operator Execution Pattern\n\n### Standard Pattern\n\n```python\n# bim\u002Fmodule\u002Fspatial\u002Foperator.py (Delivery Layer)\nclass BIM_OT_assign_container(bpy.types.Operator):\n    bl_idname = \"bim.assign_container\"\n    bl_label = \"Assign Container\"\n    bl_options = {\"REGISTER\", \"UNDO\"}\n\n    def execute(self, context):\n        return IfcStore.execute_ifc_operator(self, context)\n\n    def _execute(self, context):\n        core.spatial.assign_container(\n            tool.Ifc,        # injected concrete tool\n            tool.Spatial,\n            structure=self.structure,\n        )\n        return {\"FINISHED\"}\n```\n\n### Key Rules for Operators\n\n1. **ALWAYS** use `IfcStore.execute_ifc_operator(self, context)` — it wraps IFC operations with undo support.\n2. Put actual logic in `_execute()`, NOT in `execute()`.\n3. Pass `tool.*` classes as dependency injection parameters to `core.*` functions.\n4. **ALWAYS** include `\"UNDO\"` in `bl_options` for IFC-modifying operators.\n5. Operator namespace is `bpy.ops.bim.*` — ALWAYS use this prefix.\n\n## IfcStore: Central State Manager\n\n`IfcStore` (`bonsai\u002Fbim\u002Fifc.py`) is a **static class** — the single source of truth for all IFC state:\n\n```python\nfrom bonsai.bim.ifc import IfcStore\n\n# Key static attributes\nIfcStore.path       # str: absolute path to .ifc file\nIfcStore.file       # ifcopenshell.file | None: live in-memory IFC\nIfcStore.schema     # str: \"IFC2X3\", \"IFC4\", or \"IFC4X3\"\nIfcStore.id_map     # dict: {ifc_id (int) -> blender_object}\nIfcStore.guid_map   # dict: {GlobalId (str) -> blender_object}\nIfcStore.edited_objs  # set: objects with pending IFC changes\n\n# Key static methods\nmodel = IfcStore.get_file()        # Returns ifcopenshell.file or None\nschema = IfcStore.get_schema()     # Returns schema string\nobj = IfcStore.get_element(ifc_id) # Blender object by IFC id\n```\n\n### ALWAYS Guard Against None\n\n```python\nmodel = IfcStore.get_file()\nif model is None:\n    raise RuntimeError(\"No IFC project loaded. Open an IFC file first.\")\nwalls = model.by_type(\"IfcWall\")\n```\n\n## `tool.Ifc`: High-Level IFC Access\n\n| Method | Purpose | Returns |\n|--------|---------|---------|\n| `tool.Ifc.get()` | Live IFC file instance | `ifcopenshell.file` or `None` |\n| `tool.Ifc.set(ifc)` | Set active IFC file + post-load hooks | None |\n| `tool.Ifc.run(command, **kwargs)` | Execute `ifcopenshell.api` command | Varies |\n| `tool.Ifc.get_entity(obj)` | Blender object -> IFC entity | `entity_instance` or `None` |\n| `tool.Ifc.get_object(element)` | IFC entity -> Blender object | `bpy.types.Object` or `None` |\n| `tool.Ifc.link(element, obj)` | Create bidirectional link | None |\n\n## Blender Object \u003C-> IFC Entity Mapping\n\n```\nBlender Object                        IFC Entity\n-----------------                     ----------\nBIMObjectProperties                   ifcopenshell.entity_instance\n  .ifc_definition_id  ------------->  .id()\n                      \u003C------------- IfcStore.id_map\n  .name                               .Name\n  Matrix (loc\u002Frot\u002Fscale)              IfcLocalPlacement\n  Mesh geometry                       IfcShapeRepresentation\n```\n\n### Decision Tree: Accessing IFC Data\n\n```\nNeed IFC data from Blender object?\n|\n+--> Use tool.Ifc.get_entity(obj)\n     |\n     +--> Returns entity_instance? --> Access .GlobalId, .Name, .is_a()\n     +--> Returns None? --> Object is not linked to IFC\n\nNeed Blender object from IFC entity?\n|\n+--> Use tool.Ifc.get_object(entity)\n     |\n     +--> Returns bpy.types.Object? --> Manipulate via Blender API\n     +--> Returns None? --> Entity has no Blender representation\n\nNeed to run IFC API command?\n|\n+--> Inside Bonsai (bpy available)?\n|    +--> Use tool.Ifc.run(\"module.command\", **kwargs)\n|\n+--> Standalone (no bpy)?\n     +--> Use ifcopenshell.api.run(\"module.command\", ifc_file, **kwargs)\n```\n\n## Native IFC Workflow\n\nThe IFC file IS the document. There is NO import\u002Fexport step.\n\n| Action | What Happens |\n|--------|-------------|\n| Create new project | Empty `ifcopenshell.file` created in memory |\n| Open IFC file | `ifcopenshell.open()` loads directly into `IfcStore` |\n| Create element | IFC entity created + Blender mesh generated + bidirectional link |\n| Modify element | IFC graph updated via `ifcopenshell.api` + Blender mesh regenerated |\n| Save project | `model.write(path)` — writes live IFC directly to disk |\n\n### File Conventions\n\n- Bonsai native files: `.ifc` (saves directly to IFC, NOT `.blend`)\n- Schema versions: `IFC2X3` (legacy), `IFC4` (recommended), `IFC4X3` (latest)\n\n## Major `tool.*` Classes\n\n| Tool Class | Purpose | Key Methods |\n|-----------|---------|-------------|\n| `tool.Ifc` | IFC model access, entity\u003C->object | `get()`, `get_entity()`, `get_object()`, `run()` |\n| `tool.Spatial` | Spatial container hierarchy | `get_container()`, `get_decomposed_elements()` |\n| `tool.Geometry` | Mesh\u002Frepresentation management | `get_active_representation()`, `edit_object_placement()` |\n| `tool.Blender` | Blender scene utilities | `get_obj_ifc_definition_id()`, `set_active_object()` |\n| `tool.Pset` | Property sets management | `get_element_pset()`, `get_pset_props()` |\n| `tool.Type` | IFC type management | `get_type()`, `assign_type()` |\n| `tool.Material` | Material\u002Flayer sets | `get_material()`, `get_style()` |\n| `tool.Context` | Representation contexts | `get_context()` |\n| `tool.Style` | Visual\u002Fsurface styles | `get_style()`, `get_surface_style()` |\n| `tool.Drawing` | 2D drawing\u002Fdocumentation | `get_active_drawing()`, `get_drawing_elements()` |\n\n## BIM Property Panels\n\nBonsai extends Blender's property system with IFC-backed custom properties via `BIMObjectProperties`:\n\n- **Object Metadata**: `Properties > Object Information > Object Metadata` — IFC class, type\n- **Spatial Container**: `Properties > Object Information > Spatial Container` — containing storey\u002Fspace\n- **Property Sets**: `Properties > Object Information > Property Sets` — IFC psets\n- **Quantity Sets**: `Properties > Object Information > Quantity Sets` — IFC qtos\n\n### IFC-Backed Custom Properties\n\nBonsai registers `BIMObjectProperties` on every Blender object:\n\n```python\n# Key property: ifc_definition_id\nobj.BIMProperties.ifc_definition_id  # int: IFC entity step ID (0 = not linked)\n```\n\nProperty modifications in Blender UI panels are synced to IFC via `pset.edit_pset()`. NEVER assume modifying a Blender property alone updates the IFC data.\n\n## IfcOpenShell API Integration\n\nBonsai uses three abstraction levels for IFC operations:\n\n| Level | Module | Use When |\n|-------|--------|----------|\n| Core | `ifcopenshell.file` | Low-level entity creation\u002Fread |\n| Utility | `ifcopenshell.util.*` | Data extraction, conversions |\n| API | `ifcopenshell.api.run()` | ALL mutations (ALWAYS use this) |\n\n### Preferred: `ifcopenshell.api.run()`\n\n```python\n# ALWAYS use the API for mutations: maintains IFC graph integrity\nwall = ifcopenshell.api.run(\"root.create_entity\", model,\n    ifc_class=\"IfcWall\", name=\"Wall-001\")\n\n# NEVER modify attributes directly\n# wall.Name = \"Bad\"  # WRONG: bypasses relationship management\n```\n\n## Blender Registration\n\n```python\n# bonsai\u002F__init__.py (schematic)\nbl_info = {\n    \"name\": \"Bonsai\",\n    \"version\": (0, 8, 4),\n    \"blender\": (4, 2, 0),\n    \"category\": \"System\",\n}\n\ndef register():\n    register_classes(classes)\n    for mod in modules.values():\n        mod.register()\n    bpy.types.Scene.BIMProperties = PointerProperty(type=BIMProperties)\n\ndef unregister():\n    for mod in reversed(list(modules.values())):\n        mod.unregister()\n    unregister_classes(classes)\n```\n\n## IfcSverchok Integration (`use_bonsai_file`)\n\nIfcSverchok (Sverchok's IFC bridge) can operate on Bonsai's active IFC file instead of its own transient `SvIfcStore`:\n\n- **Toggle**: `use_bonsai_file` on `SvIfcCreateProject` node\n- **When enabled**: `SvIfcStore.get_file()` returns `tool.Ifc.get()` (Bonsai's live IFC)\n- **Effect**: Sverchok node tree writes IFC entities directly into Bonsai's model\n- **Dependency**: Bonsai addon MUST be enabled and have an active IFC project loaded\n- **Warning**: Undo\u002Fredo with simultaneous Sverchok + Bonsai modifications can crash. Save before combining.\n\nRefer to: `sverchok-impl-ifcsverchok`\n\n## Source Code Paths (IfcOpenShell Monorepo)\n\n| Component | Path |\n|-----------|------|\n| Bonsai root | `src\u002Fbonsai\u002Fbonsai\u002F` |\n| IfcStore | `src\u002Fbonsai\u002Fbonsai\u002Fbim\u002Fifc.py` |\n| Tool classes | `src\u002Fbonsai\u002Fbonsai\u002Ftool\u002F` |\n| Core functions | `src\u002Fbonsai\u002Fbonsai\u002Fcore\u002F` |\n| Module operators\u002FUI | `src\u002Fbonsai\u002Fbonsai\u002Fbim\u002Fmodule\u002F` |\n| Interface definitions | `src\u002Fbonsai\u002Fbonsai\u002Fcore\u002Ftool.py` |\n| Demo module | `src\u002Fbonsai\u002Fbonsai\u002Fbim\u002Fmodule\u002Fdemo\u002F` |\n| IfcOpenShell API | `src\u002Fifcopenshell-python\u002Fifcopenshell\u002Fapi\u002F` |\n\n## References\n\n- [methods.md](references\u002Fmethods.md) — Complete API signatures for tool.*, IfcStore, core functions\n- [examples.md](references\u002Fexamples.md) — Working code examples for common Bonsai operations\n- [anti-patterns.md](references\u002Fanti-patterns.md) — What NOT to do when scripting Bonsai\n\n## Sources\n\n- Bonsai Documentation: https:\u002F\u002Fdocs.bonsaibim.org\n- IfcOpenShell GitHub: https:\u002F\u002Fgithub.com\u002FIfcOpenShell\u002FIfcOpenShell\n- OSArch Community: https:\u002F\u002Fcommunity.osarch.org\n- IfcOpenShell API Docs: https:\u002F\u002Fdocs.ifcopenshell.org\n","# Bonsai Core Architecture\n\n> **Version**: Bonsai v0.8.4 | Blender 4.2.0+ | Python 3.11\n> **Module path**: `bonsai.*` — NEVER `blenderbim.*`\n> **Repository**: `IfcOpenShell\u002FIfcOpenShell` monorepo → `src\u002Fbonsai\u002F`\n\n## Critical Warnings\n\n1. **ALWAYS** use `bonsai.*` imports. NEVER use `blenderbim.*` — renamed in 2024 (v0.8.0+).\n2. **ALWAYS** check `IfcStore.get_file()` for `None` before any IFC operation.\n3. **NEVER** describe Bonsai workflow as \"import\u002Fexport\". The IFC file IS the document.\n4. **ALWAYS** run Bonsai scripts via `blender --python`. NEVER import `bonsai.*` from system Python.\n5. **ALWAYS** call `bpy.ops.bim.edit_object_placement()` after direct matrix\u002Flocation changes.\n6. **ALWAYS** use `ifcopenshell.api.run()` for IFC mutations, NEVER modify entity attributes directly.\n7. **NEVER** use `void.add_opening()` — use `feature.add_feature()` (changed in v0.8.0+).\n\n## Three-Layer Architecture\n\n```\n+-----------------------------------------------------+\n|  DELIVERY LAYER  — bim\u002Fmodule\u002F                       |\n|  Blender UI: operators, properties, panels, gizmos   |\n+-----------------------------------------------------+\n|  DOMAIN LAYER   — core\u002F + tool\u002F                      |\n|  Abstract use-case logic (core) + concrete impls     |\n|  (tool), injected via @interface contract             |\n+-----------------------------------------------------+\n|  DATA LAYER     — IfcStore + IFC in-memory graph     |\n|  Live ifcopenshell.file instance, id_map, guid_map   |\n+-----------------------------------------------------+\n```\n\n### Layer Rules\n\n| Layer | Location | Imports `bpy`? | Imports `ifcopenshell`? | Responsibility |\n|-------|----------|---------------|------------------------|----------------|\n| Delivery | `bim\u002Fmodule\u002F\u003Cname>\u002F` | YES | NO (via tool) | Blender UI, operators, panels |\n| Core | `core\u002F\u003Cname>.py` | NEVER | Via injected tool | Abstract use-case logic |\n| Tool | `tool\u002F\u003Cname>.py` | YES | YES | Concrete Blender + IFC operations |\n\n**Key principle**: Core NEVER imports `bpy`. All Blender-specific code lives in Tool implementations. This keeps business logic independently testable.\n\n## Module Structure Pattern\n\nEvery functional area follows a three-part split:\n\n| Sub-layer | Location | Purpose |\n|-----------|----------|---------|\n| UI (delivery) | `bim\u002Fmodule\u002F\u003Cname>\u002Fui.py`, `operator.py`, `prop.py` | Panels, operators, properties |\n| Core (abstract) | `core\u002F\u003Cname>.py` | Use-case flow, no Blender imports |\n| Tool (concrete) | `tool\u002F\u003Cname>.py` | Blender + IFC implementation |\n\n### Module File Structure\n\n| File | Purpose |\n|------|---------|\n| `__init__.py` | Package init |\n| `operator.py` | `bpy.types.Operator` subclasses (`bpy.ops.bim.*`) |\n| `prop.py` | `bpy.types.PropertyGroup` subclasses |\n| `ui.py` | Panel `draw()` methods |\n| `data.py` | Cached\u002Fcomputed UI data (refresh patterns) |\n| `decorator.py` | `bpy.types.SpaceView3D` draw callbacks (overlays) |\n| `gizmo.py` | `bpy.types.Gizmo` \u002F `GizmoGroup` subclasses |\n\n### Registered Modules (~51-56)\n\nBonsai registers approximately 51-56 functional modules, each corresponding to an IFC domain area:\n\n```\naggregate    alignment    attribute    bcf         boundary\nbrick        bsdd         cad          clash       classification\nconstraint   context      cost         covering    csv\ndebug        demo         diff         document    drawing\nfm           geometry     georeference gis         ifcgit\nlayer        library      material     nest        owner\npatch        profile      project      pset        pset_template\nqto          resource     search       sequence    spatial\nstructural   style        system       tester      type\nunit         void         web\n```\n\n### Demo Module: Reference Implementation\n\nThe `demo` module (`bim\u002Fmodule\u002Fdemo\u002F`) is a heavily commented reference implementation for new contributors. It demonstrates the full module pattern including all optional files. Enable it in `bonsai\u002Fbim\u002F__init__.py`.\n\n## The `@interface` Decorator Pattern\n\n`core\u002Ftool.py` defines tool interfaces using the `@interface` decorator — a design-by-contract enforcement mechanism:\n\n```python\n# bonsai\u002Fcore\u002Ftool.py (simplified)\n@interface\nclass Ifc:\n    def get(self): ...          # Returns ifcopenshell.file or None\n    def set(self, ifc): ...     # Sets active IFC file\n    def run(self, command, **kwargs): ...  # Runs ifcopenshell.api command\n    def get_entity(self, obj): ...        # Blender obj -> IFC entity\n    def get_object(self, element): ...    # IFC entity -> Blender obj\n    def link(self, element, obj): ...     # Bidirectional link\n\n@interface\nclass Spatial:\n    def assign_container(self, element, structure): ...\n```\n\nConcrete implementations live in `tool\u002Fifc.py`, `tool\u002Fspatial.py`, etc. Operators import them as `tool.Ifc`, `tool.Spatial`.\n\n## Operator Execution Pattern\n\n### Standard Pattern\n\n```python\n# bim\u002Fmodule\u002Fspatial\u002Foperator.py (Delivery Layer)\nclass BIM_OT_assign_container(bpy.types.Operator):\n    bl_idname = \"bim.assign_container\"\n    bl_label = \"Assign Container\"\n    bl_options = {\"REGISTER\", \"UNDO\"}\n\n    def execute(self, context):\n        return IfcStore.execute_ifc_operator(self, context)\n\n    def _execute(self, context):\n        core.spatial.assign_container(\n            tool.Ifc,        # injected concrete tool\n            tool.Spatial,\n            structure=self.structure,\n        )\n        return {\"FINISHED\"}\n```\n\n### Key Rules for Operators\n\n1. **ALWAYS** use `IfcStore.execute_ifc_operator(self, context)` — it wraps IFC operations with undo support.\n2. Put actual logic in `_execute()`, NOT in `execute()`.\n3. Pass `tool.*` classes as dependency injection parameters to `core.*` functions.\n4. **ALWAYS** include `\"UNDO\"` in `bl_options` for IFC-modifying operators.\n5. Operator namespace is `bpy.ops.bim.*` — ALWAYS use this prefix.\n\n## IfcStore: Central State Manager\n\n`IfcStore` (`bonsai\u002Fbim\u002Fifc.py`) is a **static class** — the single source of truth for all IFC state:\n\n```python\nfrom bonsai.bim.ifc import IfcStore\n\n# Key static attributes\nIfcStore.path       # str: absolute path to .ifc file\nIfcStore.file       # ifcopenshell.file | None: live in-memory IFC\nIfcStore.schema     # str: \"IFC2X3\", \"IFC4\", or \"IFC4X3\"\nIfcStore.id_map     # dict: {ifc_id (int) -> blender_object}\nIfcStore.guid_map   # dict: {GlobalId (str) -> blender_object}\nIfcStore.edited_objs  # set: objects with pending IFC changes\n\n# Key static methods\nmodel = IfcStore.get_file()        # Returns ifcopenshell.file or None\nschema = IfcStore.get_schema()     # Returns schema string\nobj = IfcStore.get_element(ifc_id) # Blender object by IFC id\n```\n\n### ALWAYS Guard Against None\n\n```python\nmodel = IfcStore.get_file()\nif model is None:\n    raise RuntimeError(\"No IFC project loaded. Open an IFC file first.\")\nwalls = model.by_type(\"IfcWall\")\n```\n\n## `tool.Ifc`: High-Level IFC Access\n\n| Method | Purpose | Returns |\n|--------|---------|---------|\n| `tool.Ifc.get()` | Live IFC file instance | `ifcopenshell.file` or `None` |\n| `tool.Ifc.set(ifc)` | Set active IFC file + post-load hooks | None |\n| `tool.Ifc.run(command, **kwargs)` | Execute `ifcopenshell.api` command | Varies |\n| `tool.Ifc.get_entity(obj)` | Blender object -> IFC entity | `entity_instance` or `None` |\n| `tool.Ifc.get_object(element)` | IFC entity -> Blender object | `bpy.types.Object` or `None` |\n| `tool.Ifc.link(element, obj)` | Create bidirectional link | None |\n\n## Blender Object \u003C-> IFC Entity Mapping\n\n```\nBlender Object                        IFC Entity\n-----------------                     ----------\nBIMObjectProperties                   ifcopenshell.entity_instance\n  .ifc_definition_id  ------------->  .id()\n                      \u003C------------- IfcStore.id_map\n  .name                               .Name\n  Matrix (loc\u002Frot\u002Fscale)              IfcLocalPlacement\n  Mesh geometry                       IfcShapeRepresentation\n```\n\n### Decision Tree: Accessing IFC Data\n\n```\nNeed IFC data from Blender object?\n|\n+--> Use tool.Ifc.get_entity(obj)\n     |\n     +--> Returns entity_instance? --> Access .GlobalId, .Name, .is_a()\n     +--> Returns None? --> Object is not linked to IFC\n\nNeed Blender object from IFC entity?\n|\n+--> Use tool.Ifc.get_object(entity)\n     |\n     +--> Returns bpy.types.Object? --> Manipulate via Blender API\n     +--> Returns None? --> Entity has no Blender representation\n\nNeed to run IFC API command?\n|\n+--> Inside Bonsai (bpy available)?\n|    +--> Use tool.Ifc.run(\"module.command\", **kwargs)\n|\n+--> Standalone (no bpy)?\n     +--> Use ifcopenshell.api.run(\"module.command\", ifc_file, **kwargs)\n```\n\n## Native IFC Workflow\n\nThe IFC file IS the document. There is NO import\u002Fexport step.\n\n| Action | What Happens |\n|--------|-------------|\n| Create new project | Empty `ifcopenshell.file` created in memory |\n| Open IFC file | `ifcopenshell.open()` loads directly into `IfcStore` |\n| Create element | IFC entity created + Blender mesh generated + bidirectional link |\n| Modify element | IFC graph updated via `ifcopenshell.api` + Blender mesh regenerated |\n| Save project | `model.write(path)` — writes live IFC directly to disk |\n\n### File Conventions\n\n- Bonsai native files: `.ifc` (saves directly to IFC, NOT `.blend`)\n- Schema versions: `IFC2X3` (legacy), `IFC4` (recommended), `IFC4X3` (latest)\n\n## Major `tool.*` Classes\n\n| Tool Class | Purpose | Key Methods |\n|-----------|---------|-------------|\n| `tool.Ifc` | IFC model access, entity\u003C->object | `get()`, `get_entity()`, `get_object()`, `run()` |\n| `tool.Spatial` | Spatial container hierarchy | `get_container()`, `get_decomposed_elements()` |\n| `tool.Geometry` | Mesh\u002Frepresentation management | `get_active_representation()`, `edit_object_placement()` |\n| `tool.Blender` | Blender scene utilities | `get_obj_ifc_definition_id()`, `set_active_object()` |\n| `tool.Pset` | Property sets management | `get_element_pset()`, `get_pset_props()` |\n| `tool.Type` | IFC type management | `get_type()`, `assign_type()` |\n| `tool.Material` | Material\u002Flayer sets | `get_material()`, `get_style()` |\n| `tool.Context` | Representation contexts | `get_context()` |\n| `tool.Style` | Visual\u002Fsurface styles | `get_style()`, `get_surface_style()` |\n| `tool.Drawing` | 2D drawing\u002Fdocumentation | `get_active_drawing()`, `get_drawing_elements()` |\n\n## BIM Property Panels\n\nBonsai extends Blender's property system with IFC-backed custom properties via `BIMObjectProperties`:\n\n- **Object Metadata**: `Properties > Object Information > Object Metadata` — IFC class, type\n- **Spatial Container**: `Properties > Object Information > Spatial Container` — containing storey\u002Fspace\n- **Property Sets**: `Properties > Object Information > Property Sets` — IFC psets\n- **Quantity Sets**: `Properties > Object Information > Quantity Sets` — IFC qtos\n\n### IFC-Backed Custom Properties\n\nBonsai registers `BIMObjectProperties` on every Blender object:\n\n```python\n# Key property: ifc_definition_id\nobj.BIMProperties.ifc_definition_id  # int: IFC entity step ID (0 = not linked)\n```\n\nProperty modifications in Blender UI panels are synced to IFC via `pset.edit_pset()`. NEVER assume modifying a Blender property alone updates the IFC data.\n\n## IfcOpenShell API Integration\n\nBonsai uses three abstraction levels for IFC operations:\n\n| Level | Module | Use When |\n|-------|--------|----------|\n| Core | `ifcopenshell.file` | Low-level entity creation\u002Fread |\n| Utility | `ifcopenshell.util.*` | Data extraction, conversions |\n| API | `ifcopenshell.api.run()` | ALL mutations (ALWAYS use this) |\n\n### Preferred: `ifcopenshell.api.run()`\n\n```python\n# ALWAYS use the API for mutations: maintains IFC graph integrity\nwall = ifcopenshell.api.run(\"root.create_entity\", model,\n    ifc_class=\"IfcWall\", name=\"Wall-001\")\n\n# NEVER modify attributes directly\n# wall.Name = \"Bad\"  # WRONG: bypasses relationship management\n```\n\n## Blender Registration\n\n```python\n# bonsai\u002F__init__.py (schematic)\nbl_info = {\n    \"name\": \"Bonsai\",\n    \"version\": (0, 8, 4),\n    \"blender\": (4, 2, 0),\n    \"category\": \"System\",\n}\n\ndef register():\n    register_classes(classes)\n    for mod in modules.values():\n        mod.register()\n    bpy.types.Scene.BIMProperties = PointerProperty(type=BIMProperties)\n\ndef unregister():\n    for mod in reversed(list(modules.values())):\n        mod.unregister()\n    unregister_classes(classes)\n```\n\n## IfcSverchok Integration (`use_bonsai_file`)\n\nIfcSverchok (Sverchok's IFC bridge) can operate on Bonsai's active IFC file instead of its own transient `SvIfcStore`:\n\n- **Toggle**: `use_bonsai_file` on `SvIfcCreateProject` node\n- **When enabled**: `SvIfcStore.get_file()` returns `tool.Ifc.get()` (Bonsai's live IFC)\n- **Effect**: Sverchok node tree writes IFC entities directly into Bonsai's model\n- **Dependency**: Bonsai addon MUST be enabled and have an active IFC project loaded\n- **Warning**: Undo\u002Fredo with simultaneous Sverchok + Bonsai modifications can crash. Save before combining.\n\nRefer to: `sverchok-impl-ifcsverchok`\n\n## Source Code Paths (IfcOpenShell Monorepo)\n\n| Component | Path |\n|-----------|------|\n| Bonsai root | `src\u002Fbonsai\u002Fbonsai\u002F` |\n| IfcStore | `src\u002Fbonsai\u002Fbonsai\u002Fbim\u002Fifc.py` |\n| Tool classes | `src\u002Fbonsai\u002Fbonsai\u002Ftool\u002F` |\n| Core functions | `src\u002Fbonsai\u002Fbonsai\u002Fcore\u002F` |\n| Module operators\u002FUI | `src\u002Fbonsai\u002Fbonsai\u002Fbim\u002Fmodule\u002F` |\n| Interface definitions | `src\u002Fbonsai\u002Fbonsai\u002Fcore\u002Ftool.py` |\n| Demo module | `src\u002Fbonsai\u002Fbonsai\u002Fbim\u002Fmodule\u002Fdemo\u002F` |\n| IfcOpenShell API | `src\u002Fifcopenshell-python\u002Fifcopenshell\u002Fapi\u002F` |\n\n## References\n\n- [methods.md](references\u002Fmethods.md) — Complete API signatures for tool.*, IfcStore, core functions\n- [examples.md](references\u002Fexamples.md) — Working code examples for common Bonsai operations\n- [anti-patterns.md](references\u002Fanti-patterns.md) — What NOT to do when scripting Bonsai\n\n## Sources\n\n- Bonsai Documentation: https:\u002F\u002Fdocs.bonsaibim.org\n- IfcOpenShell GitHub: https:\u002F\u002Fgithub.com\u002FIfcOpenShell\u002FIfcOpenShell\n- OSArch Community: https:\u002F\u002Fcommunity.osarch.org\n- IfcOpenShell API Docs: https:\u002F\u002Fdocs.ifcopenshell.org\n",{"name":5,"license":14,"version":23,"metadata":24,"description":27,"compatibility":28},"Bonsai v0.8.4 | Minimum Blender: 4.2.0 | Python 3.11",{"author":25,"version":26},"OpenAEC-Foundation","1.0","Use when developing Bonsai (formerly BlenderBIM) extensions, scripting BIM workflows in Blender, or understanding the Bonsai addon architecture. Prevents the common mistake of using ifcopenshell.open() to access the model instead of tool.Ifc.get() which gives the live Bonsai IFC file. Covers native IFC workflow, bpy.ops.bim.* operators, BIM property panels, and the relationship between Blender objects and IFC entities. Keywords: Bonsai, BlenderBIM, tool.Ifc.get(), bpy.ops.bim, native IFC, addon architecture, IFC-backed properties, BIM authoring, how does Bonsai work, Bonsai internals, Bonsai API.\n","Designed for Claude Code. Requires Blender 4.2.0+ with Bonsai v0.8.4+ and Python 3.11.","main","9bb7acf0c2ec4f44373969cb14e55af3c9a8385f","plugins\u002Fblender-bim-sverchok\u002Fskills\u002Fbonsai\u002Fcore\u002Fbonsai-core-architecture","https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d","https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot","2026-11-09 13:26:47",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add lagzgabrielmuller-dot\u002Fkit-ingenieria-3d --skill bonsai-core-architecture",{"tool":41,"command":42},"bunx","bunx skills add lagzgabrielmuller-dot\u002Fkit-ingenieria-3d --skill bonsai-core-architecture",{"tool":44,"command":45},"pnpm","pnpm dlx skills add lagzgabrielmuller-dot\u002Fkit-ingenieria-3d --skill bonsai-core-architecture","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fblender-bim-sverchok\u002Fskills\u002Fbonsai\u002Fcore\u002Fbonsai-core-architecture\u002FSKILL.md",true,[49,55,59],{"path":50,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":53,"sourceHtmlUrl":54},"references\u002Fanti-patterns.md","REFERENCE","参考文档",14188,"https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fblender-bim-sverchok\u002Fskills\u002Fbonsai\u002Fcore\u002Fbonsai-core-architecture\u002Freferences\u002Fanti-patterns.md",{"path":56,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":57,"sourceHtmlUrl":58},"references\u002Fexamples.md",13894,"https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fblender-bim-sverchok\u002Fskills\u002Fbonsai\u002Fcore\u002Fbonsai-core-architecture\u002Freferences\u002Fexamples.md",{"path":60,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":61,"sourceHtmlUrl":62},"references\u002Fmethods.md",11077,"https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fblender-bim-sverchok\u002Fskills\u002Fbonsai\u002Fcore\u002Fbonsai-core-architecture\u002Freferences\u002Fmethods.md",[64,72,79,86,93,100],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":68,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":18},"01M7FBFSZ93YM463CGS91D0TZG","manimce-best-practices","Trigger when: (1) User mentions \"manim\" or \"Manim Community\" or \"ManimCE\", (2) Code contains `from manim import *`, (3) User runs `manim` CLI commands, (4) Working with Scene, MathTex, Create(), or ManimCE-specific classes.\n\nBest practices for Manim Community Edition - the community-maintained Python animation engine. Covers Scene structure, animations, LaTeX\u002FMathTex, 3D with ThreeDScene, camera control, styling, and CLI usage.\n\nNOT for ManimGL\u002F3b1b version (which uses `manimlib` imports and `manimgl` CLI).","https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fmanim-animaciones\u002Fskills\u002Fmanimce-best-practices\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fmanim-animaciones\u002Fskills\u002Fmanimce-best-practices\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":18},"01M7FB2K59HNNXS9WKHAMWHC3C","drawio","Create, edit, replicate, import, and export draw.io diagrams with an offline YAML-first workflow: architecture, network topologies, flowcharts, UML\u002FER, org charts, Mermaid\u002FCSV conversion, existing .drawio bundles, style presets, themes, and non-publication formula diagrams. For publication figures (paper, thesis, IEEE, camera-ready) use drawio-academic-skills instead.","https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fdiagramas-y-documentos\u002Fskills\u002Fdrawio\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":18},"01M7FB2BWX7GWK9H2X8BGCYDDD","drawio-academic-skills","Publication-figure overlay for draw.io. Use instead of drawio whenever the diagram is for a paper, thesis, dissertation, journal, conference, IEEE\u002FACM submission, manuscript, camera-ready, Word\u002FLaTeX figure, or other publication. Applies venue, figure-type, color, caption\u002Flegend, formula, and paper-readability gates for architecture, workflow, roadmap, network-topology, and replicated paper figures.","https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fdiagramas-y-documentos\u002Fskills\u002Fdrawio-academic-skills\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":18},"01M7FB22JESEAV8T15DJT3D444","uncertainty-and-units","Tracks physical units and propagates measurement uncertainty in scientific calculations using pint and uncertainties. Use for unit conversion and dimensional checking, GUM uncertainty budgets, Type A and Type B evaluation, coverage factors and expanded uncertainty, Monte Carlo propagation, significant-figure and plus-minus reporting, error propagation through curve fits, CODATA constants, auditing Python code for stripped units or broken uncertainty propagation, and order-of-magnitude plausibility checks using dimensionless groups (Reynolds, Peclet, Damkohler, Knudsen, Biot, Womersley), characteristic scales such as diffusion time or Debye length, and observed magnitude ranges. Trigger on \"is this number physically reasonable\", \"sanity check these units\", \"what regime is this flow in\", or a result that looks off by orders of magnitude.","https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fciencia-y-calculo\u002Fskills\u002Funcertainty-and-units\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":18},"01M7FB1ANRSG28R335FDY9SA3R","statistical-analysis","Guided statistical analysis for research data - test selection, assumption checking, effect sizes, power analysis, Bayesian alternatives, and APA-formatted reporting. Use whenever a user wants to compare groups, test a hypothesis, analyze experimental or survey data, check statistical assumptions, compute required sample sizes, or write up results - even if they never name a specific test. Covers t-tests, ANOVA, chi-square, correlation, regression, non-parametric and Bayesian methods. For low-level model APIs, see the statsmodels and pymc skills.","https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fciencia-y-calculo\u002Fskills\u002Fstatistical-analysis\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":18},"01M7FB15KRA9D7JCPH4P9T6XJY","simpy","Builds, inspects, tests, and analyzes bounded process-based discrete-event simulations with SimPy. Use for event scheduling, resource queues, interrupts, monitoring, independent replications, warm-up, and reproducible output analysis.","https:\u002F\u002Fgithub.com\u002Flagzgabrielmuller-dot\u002Fkit-ingenieria-3d\u002Fblob\u002Fmain\u002Fplugins\u002Fciencia-y-calculo\u002Fskills\u002Fsimpy\u002FSKILL.md",[],[]]