Логотип Bonsai Syntax Elements

Bonsai Syntax Elements

Організація
Impertio-Studio
bonsai-syntax-elements

Use when accessing IFC elements from Blender objects in Bonsai -- getting the IFC entity behind a selected object, or finding which Blender object represents an IFC element. Prevents the common mistake of using ifcopenshell.open() instead of tool.Ifc.get() to access the live Bonsai file. Covers element-to-object mapping, IfcStore retrieval, and the Bonsai data bridge between bpy.types.Object and IFC entities. Keywords: tool.Ifc.get(), IfcStore, element mapping, Blender object to IFC, IFC entity, selected element, data bridge, Bonsai elements, get IFC from selected, which element is this.

Огляд

ВидавецьImpertio-Studio
РепозиторійBlender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package
Назва навичкиbonsai-syntax-elements
Зірки
44
Форки
5
Файли в пакеті
3
ЛіцензіяMIT
Посилання
  • Інструкції у форматі Markdown

    Файл SKILL.md, який модель завантажує за потреби, тож токени витрачаються лише тоді, коли запит справді відповідає навичці.

  • Працює з будь-якою LLM

    Навички ШІ — це звичайний Markdown, а не код для певного постачальника, тому вони працюють із GPT, Claude, Gemini, Grok або локальною моделлю.

  • Файлів у комплекті: 3

    Скрипти, шаблони й довідкові матеріали, які модель може читати під час роботи. Файли доступні лише для читання й ніколи не виконуються.

  • Відкритий вихідний код

    Опубліковано на GitHub користувачем Impertio-Studio. Перегляньте вихідний вміст перед установленням.

Встановлення

Установіть навичку ШІ Bonsai Syntax Elements у TypingMind, щоб використовувати її з будь-якою LLM, або додайте її до іншого агента, що читає SKILL.md.

1

Встановити в TypingMind

TypingMind встановлює навичку безпосередньо з її папки GitHub — читає SKILL.md, збирає файли ресурсів у пакет і зберігає результат локально.

  1. Відкрийте застосунок і перейдіть до Плагіни → Навички.
  2. Виберіть «Встановити з GitHub».
  3. Вставте наведений нижче URL папки навички та підтвердьте встановлення.
    https://github.com/Impertio-Studio/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package/tree/main/skills/bonsai/syntax/bonsai-syntax-elements
  4. Увімкніть навичку в кожному чаті, де хочете її використовувати.
Плагіни → Навички → Нова навичка → За URL GitHub, потім вставте URL папки й натисніть «Продовжити».
2

Встановити в іншому агенті

Будь-який агент, що підтримує формат Agent Skills, може використовувати цю навичку — скопіюйте папку до каталогу навичок цього агента.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Impertio-Studio/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package.git /tmp/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package
mkdir -p .claude/skills
cp -r /tmp/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package/skills/bonsai/syntax/bonsai-syntax-elements .claude/skills/bonsai-syntax-elements
Після копіювання перезапустіть Claude Code, щоб завантажити нову навичку.

Використовуйте навичку в TypingMind

Увімкніть навичку Bonsai Syntax Elements в будь-якому чаті TypingMind, і далі модель усе зробить сама. Назва й опис навички містяться в системному промпті, а щойно надходить відповідний запит, модель самостійно завантажує повні інструкції — вам не потрібно викликати навичку вручну, і до фактичного використання вона не витрачає токенів.

Модель самостійно завантажує навичку Bonsai Syntax Elements, щойно надходить відповідний запит.

Працює з будь-якою моделлю ШІ

Навички ШІ — це звичайні інструкції Markdown, а не код для певного постачальника, тому навичка Bonsai Syntax Elements не прив’язана до моделі, для якої її створено. Установіть її один раз у TypingMind і використовуйте з GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama або локальною моделлю, яку ви запускаєте самостійно, — усе з вашими власними ключами API.

  • Завантажується лише за потреби

    Системний промпт містить лише назву й опис. Інструкції завантажуються за першого відповідного запиту, тож невикористана навичка нічого не коштує.

  • Змінюйте моделі під час чату

    Оскільки навичка — це інструкції, а не код, зміна моделі не порушує її роботу: наступна модель читає той самий файл SKILL.md.

Інструкції навички

Це вміст файлу SKILL.md, який завантажує модель. Прочитайте його перед установленням — навичка містить інструкції, яких дотримуватиметься ваша модель.

Bonsai IFC Element Access Syntax

Version: Bonsai v0.8.4 | Blender 4.2.0+ | Python 3.11 Module path: bonsai.* — NEVER blenderbim.* Dependencies: bonsai-core-architecture, ifcos-syntax-api

Critical Warnings

  1. ALWAYS use bonsai.* imports. NEVER use blenderbim.* — renamed in 2024 (v0.8.0+).
  2. ALWAYS check IfcStore.get_file() and tool.Ifc.get() for None before any IFC operation.
  3. ALWAYS use tool.Ifc.get_entity(obj) to get an IFC entity from a Blender object. NEVER read obj.BIMProperties.ifc_definition_id and call model.by_id() manually — the tool method handles edge cases.
  4. NEVER assume every Blender object has an IFC entity. get_entity() returns None for non-IFC objects.
  5. NEVER assume every IFC entity has a Blender object. get_object() returns None for entities without scene representation.
  6. ALWAYS run element access code inside Blender (blender --python). bonsai.tool.* depends on bpy and CANNOT run in standalone Python.
  7. NEVER cache IFC entity references across file reloads. Entity instances become stale when the IFC file is reloaded.
  8. ALWAYS use tool.Ifc.link(element, obj) to create bidirectional mappings. NEVER manually populate IfcStore.id_map or IfcStore.guid_map.

Decision Tree: How to Access IFC Elements

What do you have?
│
├── A Blender object (bpy.types.Object)?
│   │
│   ├── Need the IFC entity?
│   │   └── tool.Ifc.get_entity(obj)
│   │       ├── Returns entity_instance → access .GlobalId, .Name, .is_a(), attributes
│   │       └── Returns None → object is NOT linked to IFC
│   │
│   ├── Need just the IFC step ID?
│   │   └── obj.BIMProperties.ifc_definition_id
│   │       ├── Returns int > 0 → linked to IFC entity with that step ID
│   │       └── Returns 0 → NOT linked to IFC
│   │
│   └── Need IFC class name?
│       └── entity = tool.Ifc.get_entity(obj)
│           └── entity.is_a()  # "IfcWall", "IfcSlab", etc.
│
├── An IFC entity (ifcopenshell.entity_instance)?
│   │
│   ├── Need the Blender object?
│   │   └── tool.Ifc.get_object(entity)
│   │       ├── Returns bpy.types.Object → manipulate via Blender API
│   │       └── Returns None → entity has no Blender scene representation
│   │
│   └── Need another entity related to this one?
│       ├── Type definition?
│       │   └── ifcopenshell.util.element.get_type(entity)
│       ├── Spatial container?
│       │   └── ifcopenshell.util.element.get_container(entity)
│       ├── Property sets?
│       │   └── ifcopenshell.util.element.get_psets(entity)
│       └── Material?
│           └── ifcopenshell.util.element.get_material(entity)
│
├── An IFC class name (string)?
│   │
│   └── Need all entities of that class?
│       └── model = tool.Ifc.get()
│           └── model.by_type("IfcWall")  # Returns list of entity_instance
│
├── An IFC GlobalId (string)?
│   │
│   └── model = tool.Ifc.get()
│       └── model.by_guid("2O2Fr$t4X7Zf8...")  # Returns entity_instance
│
├── An IFC step ID (int)?
│   │
│   ├── Need the IFC entity?
│   │   └── model = tool.Ifc.get()
│   │       └── model.by_id(step_id)  # Returns entity_instance
│   │
│   └── Need the Blender object directly?
│       └── IfcStore.id_map.get(step_id)  # Returns bpy.types.Object or None
│
└── Nothing — need to discover elements?
    │
    ├── All elements in the model?
    │   └── model.by_type("IfcElement")  # All physical elements
    │
    ├── All elements in a specific storey?
    │   └── ifcopenshell.util.element.get_decomposition(storey)
    │
    └── All elements matching a query?
        └── Use ifcopenshell.util.selector (CSS-like syntax)

Essential Patterns

Pattern 1: Get the Live IFC File

python
# Bonsai v0.8.x: inside Blender context

# Method A: via tool.Ifc (preferred in Bonsai tool/core code)
import bonsai.tool as tool

model = tool.Ifc.get()
if model is None:
    raise RuntimeError("No IFC project loaded.")

# Method B: via IfcStore (equivalent, used in operator code)
from bonsai.bim.ifc import IfcStore

model = IfcStore.get_file()
if model is None:
    raise RuntimeError("No IFC project loaded.")

tool.Ifc.get() and IfcStore.get_file() return the same ifcopenshell.file instance. Use tool.Ifc.get() in tool/core code; use IfcStore.get_file() in operator/UI code.

Pattern 2: Blender Object → IFC Entity

python
# Bonsai v0.8.x: inside Blender context
import bpy
import bonsai.tool as tool

obj = bpy.context.active_object
entity = tool.Ifc.get_entity(obj)

if entity is None:
    print(f"{obj.name} is not linked to IFC")
else:
    print(f"IFC class: {entity.is_a()}")
    print(f"GlobalId:  {entity.GlobalId}")
    print(f"Name:      {entity.Name}")
    print(f"Step ID:   {entity.id()}")

Pattern 3: IFC Entity → Blender Object

python
# Bonsai v0.8.x: inside Blender context
import bonsai.tool as tool

model = tool.Ifc.get()
wall = model.by_type("IfcWall")[0]
obj = tool.Ifc.get_object(wall)

if obj is None:
    print(f"Wall {wall.Name} has no Blender representation")
else:
    print(f"Blender object: {obj.name}")
    obj.select_set(True)  # Select in viewport

Pattern 4: Query Elements by Type

python
# Bonsai v0.8.x: inside Blender context
import bonsai.tool as tool

model = tool.Ifc.get()
if model is None:
    raise RuntimeError("No IFC project loaded.")

# All walls
walls = model.by_type("IfcWall")

# All physical elements (walls, slabs, columns, doors, etc.)
elements = model.by_type("IfcElement")

# All spatial elements (sites, buildings, storeys, spaces)
spatial = model.by_type("IfcSpatialElement")  # IFC4+
# For IFC2X3: model.by_type("IfcSpatialStructureElement")

# Specific type with subtypes excluded
walls_only = model.by_type("IfcWall", include_subtypes=False)
# Excludes IfcWallStandardCase (IFC2X3) and subtypes

Pattern 5: Look Up by GlobalId or Step ID

python
# Bonsai v0.8.x: inside Blender context
import bonsai.tool as tool
from bonsai.bim.ifc import IfcStore

model = tool.Ifc.get()

# By GlobalId (22-character IFC identifier)
entity = model.by_guid("2O2Fr$t4X7Zf8NOew3FLOH")

# By step ID (integer)
entity = model.by_id(42)

# Step ID → Blender object (direct lookup, bypasses entity)
obj = IfcStore.id_map.get(42)

# GlobalId → Blender object (direct lookup)
obj = IfcStore.guid_map.get("2O2Fr$t4X7Zf8NOew3FLOH")

Pattern 6: Navigate Entity Relationships

python
# Bonsai v0.8.x: inside Blender context
import bonsai.tool as tool
import ifcopenshell.util.element

model = tool.Ifc.get()
wall = model.by_type("IfcWall")[0]

# Get the spatial container (storey/space) of an element
container = ifcopenshell.util.element.get_container(wall)
if container:
    print(f"Wall is in: {container.Name} ({container.is_a()})")

# Get the type definition
wall_type = ifcopenshell.util.element.get_type(wall)
if wall_type:
    print(f"Wall type: {wall_type.Name}")

# Get all property sets
psets = ifcopenshell.util.element.get_psets(wall)
for pset_name, props in psets.items():
    print(f"  {pset_name}: {props}")

# Get material
material = ifcopenshell.util.element.get_material(wall)
if material:
    print(f"Material: {material.is_a()} — {material.Name}")

Pattern 7: Iterate Over All Elements with Blender Objects

python
# Bonsai v0.8.x: inside Blender context
import bonsai.tool as tool
from bonsai.bim.ifc import IfcStore

model = tool.Ifc.get()

# Method A: Iterate IfcStore.id_map (fastest for Blender-linked elements)
for ifc_id, obj in IfcStore.id_map.items():
    entity = model.by_id(ifc_id)
    print(f"{obj.name} → {entity.is_a()} ({entity.Name})")

# Method B: Iterate IFC entities and look up Blender objects
for wall in model.by_type("IfcWall"):
    obj = tool.Ifc.get_object(wall)
    if obj:
        print(f"{wall.Name} → {obj.name}")

Pattern 8: Check if Object is IFC-Linked

python
# Bonsai v0.8.x: inside Blender context
import bpy

obj = bpy.context.active_object

# Quick check via property (no tool import needed)
ifc_id = obj.BIMProperties.ifc_definition_id
if ifc_id == 0:
    print("Not linked to IFC")
else:
    print(f"Linked to IFC entity #{ifc_id}")

# Full check with entity retrieval
import bonsai.tool as tool
entity = tool.Ifc.get_entity(obj)
is_ifc_linked = entity is not None

The Blender-IFC Data Bridge

Mapping Architecture

Blender Side                          IFC Side
───────────────────────                ────────────────────────
bpy.types.Object                      ifcopenshell.entity_instance
  .name                    ←→          .Name
  .BIMProperties
    .ifc_definition_id     ────→       .id()  (step ID)
                           ←────       IfcStore.id_map[id]
  .matrix_world            ←→          IfcLocalPlacement
  .data (Mesh)             ←→          IfcShapeRepresentation

           tool.Ifc.get_entity(obj)  ──→
           tool.Ifc.get_object(ent)  ←──
           tool.Ifc.link(ent, obj)   ←→  bidirectional registration

Key Properties on Blender Objects

PropertyTypeAccessDescription
obj.BIMProperties.ifc_definition_idintReadIFC step ID. 0 = not linked.
obj.namestrRead/WriteBlender object name (may differ from IFC Name)
obj.matrix_worldMatrixRead/WriteWorld-space transform (sync to IFC via edit_object_placement)
obj.databpy.types.MeshReadGeometry data (regenerated from IFC representations)

Mapping Lookup Tables

LookupData StructureDirectionKey → Value
IfcStore.id_mapdictIFC → Blenderint (step ID) → bpy.types.Object
IfcStore.guid_mapdictIFC → Blenderstr (GlobalId) → bpy.types.Object
obj.BIMProperties.ifc_definition_idPropertyBlender → IFCbpy.types.Object → int (step ID)

IfcStore Element Access Methods

Quick Reference

MethodInputReturnsUse When
IfcStore.get_file()—ifcopenshell.file | NoneGetting the live IFC model
IfcStore.get_element(ifc_id)intbpy.types.Object | NoneLooking up Blender object by step ID
IfcStore.id_map—dict[int, Object]Iterating all linked objects
IfcStore.guid_map—dict[str, Object]Looking up by GlobalId
tool.Ifc.get()—ifcopenshell.file | NoneSame as get_file() (tool layer)
tool.Ifc.get_entity(obj)Objectentity_instance | NoneObject → IFC entity
tool.Ifc.get_object(element)entity_instanceObject | NoneIFC entity → Object
tool.Ifc.link(element, obj)BothNoneRegister bidirectional mapping

ifcopenshell.file Query Methods

These methods are called on the ifcopenshell.file instance returned by tool.Ifc.get() or IfcStore.get_file().

MethodSignatureReturnsDescription
by_type(type)(type: str, include_subtypes=True) -> listList of entitiesAll entities of a given IFC class
by_id(id)(id: int) -> entity_instanceSingle entityEntity by step ID. Raises RuntimeError if not found.
by_guid(guid)(guid: str) -> entity_instanceSingle entityEntity by GlobalId. Raises RuntimeError if not found.

ALWAYS Wrap Lookups in Try/Except When ID Source is External

python
model = tool.Ifc.get()
try:
    entity = model.by_id(user_provided_id)
except RuntimeError:
    print(f"No entity with step ID {user_provided_id}")

ifcopenshell.util.element: Relationship Navigation

FunctionSignatureReturnsDescription
get_container(element)(element) -> entity | NoneSpatial containerIfcBuildingStorey, IfcSpace, etc.
get_type(element)(element) -> entity | NoneType definitionIfcWallType, IfcSlabType, etc.
get_types(type_element)(type_element) -> listOccurrencesAll instances of a type
get_psets(element)(element, psets_only=False, qtos_only=False, should_inherit=True) -> dictProperty dictAll psets/qtos as nested dict
get_material(element)(element) -> entity | NoneMaterialIfcMaterial, IfcMaterialLayerSet, etc.
get_decomposition(element)(element) -> listChildrenAll decomposed child elements
get_aggregate(element)(element) -> entity | NoneParentAggregating parent element

Common Operations

Select All Elements of a Type in Viewport

python
# Bonsai v0.8.x: select all IfcDoor objects in Blender viewport
import bpy
import bonsai.tool as tool

model = tool.Ifc.get()
if model is None:
    raise RuntimeError("No IFC project loaded.")

bpy.ops.object.select_all(action='DESELECT')
for door in model.by_type("IfcDoor"):
    obj = tool.Ifc.get_object(door)
    if obj:
        obj.select_set(True)

Get Property Value from Active Object

python
# Bonsai v0.8.x: read FireRating from active object
import bpy
import bonsai.tool as tool
import ifcopenshell.util.element

obj = bpy.context.active_object
entity = tool.Ifc.get_entity(obj)
if entity:
    psets = ifcopenshell.util.element.get_psets(entity)
    wall_common = psets.get("Pset_WallCommon", {})
    fire_rating = wall_common.get("FireRating")
    print(f"FireRating: {fire_rating}")

List All Elements in a Storey

python
# Bonsai v0.8.x: list all elements contained in first storey
import bonsai.tool as tool
import ifcopenshell.util.element

model = tool.Ifc.get()
storey = model.by_type("IfcBuildingStorey")[0]
elements = ifcopenshell.util.element.get_decomposition(storey)
for el in elements:
    print(f"  {el.is_a()}: {el.Name} (#{el.id()})")

Version Notes

Bonsai v0.8.0+ (2024 Rename)

ChangeBefore (BlenderBIM)After (Bonsai v0.8.0+)
Module pathblenderbim.*bonsai.*
IfcStore importfrom blenderbim.bim.ifc import IfcStorefrom bonsai.bim.ifc import IfcStore
Tool importimport blenderbim.tool as toolimport bonsai.tool as tool
Core importimport blenderbim.core.spatialimport bonsai.core.spatial

IfcOpenShell v0.8+ List Parameters

Since IfcOpenShell v0.8, most relationship API functions use list parameters (products, related_objects) instead of singular. This affects tool.Ifc.run() calls:

python
# CORRECT (v0.8+)
tool.Ifc.run("spatial.assign_container",
    products=[wall], relating_structure=storey)

# WRONG (pre-v0.8 style)
tool.Ifc.run("spatial.assign_container",
    product=wall, relating_structure=storey)  # KeyError

Reference Links

Dependencies

  • bonsai-core-architecture — Three-layer architecture, IfcStore overview, operator pattern
  • ifcos-syntax-api — ifcopenshell.api.run() invocation patterns, module table

Sources

  • Bonsai source: src/bonsai/bonsai/bim/ifc.py (IfcStore)
  • Bonsai source: src/bonsai/bonsai/tool/ifc.py (tool.Ifc implementation)
  • Bonsai source: src/bonsai/bonsai/core/tool.py (@interface definitions)
  • IfcOpenShell API: https://docs.ifcopenshell.org
  • Bonsai Documentation: https://docs.bonsaibim.org

Файли в пакеті

Модель читає ці файли за потреби, поки навичку завантажено. Вони доступні для читання й ніколи не виконуються.

Поширені запитання

Що робить навичка ШІ Bonsai Syntax Elements?

Use when accessing IFC elements from Blender objects in Bonsai -- getting the IFC entity behind a selected object, or finding which Blender object represents an IFC element. Prevents the common mistake of using ifcopenshell.open() instead of tool.Ifc.get() to access the live Bonsai file. Covers element-to-object mapping, IfcStore retrieval, and the Bonsai data bridge between bpy.types.Object and IFC entities. Keywords: tool.Ifc.get(), IfcStore, element mapping, Blender object to IFC, IFC entity, selected element, data bridge, Bonsai elements, get IFC from selected, which element is this.

Навіщо використовувати Bonsai Syntax Elements у TypingMind?

Тому що ви встановлюєте її один раз і використовуєте з будь-якою моделлю. Bonsai Syntax Elements — це звичайний Markdown, а не код для конкретного постачальника, тому та сама навичка працює з GPT-5, Claude, Gemini, Grok або локальною моделлю. Ви можете змінити модель навіть посеред чату, і навичка продовжить працювати. TypingMind використовує ваші власні ключі API, тож ви платите безпосередньо постачальникам замість передплати за кожне місце користувача, а ваші навички й чати залишаються у вашому сховищі.

Як встановити Bonsai Syntax Elements у TypingMind?

Відкрийте в TypingMind Плагіни → Навички → Встановити з GitHub і вставте https://github.com/Impertio-Studio/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package/tree/main/skills/bonsai/syntax/bonsai-syntax-elements. TypingMind прочитає файл SKILL.md, додасть супровідні файли та встановить навичку, яку можна вмикати окремо для кожного чату.

Які моделі ШІ можуть використовувати Bonsai Syntax Elements?

Будь-яка модель, яку ви підключите в TypingMind. Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для конкретного постачальника, тому GPT, Claude, Gemini, Grok і локальні моделі можуть завантажувати цю навичку, коли запит їй відповідає.

Зі скількома моделями ШІ можна використовувати Bonsai Syntax Elements?

Зі скількома забажаєте. Якщо модель підтримує навички, ви можете використовувати з нею Bonsai Syntax Elements — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama та інші — усе в TypingMind із власними ключами API.

Чи безкоштовна навичка ШІ Bonsai Syntax Elements?

Так. Навичку опубліковано на GitHub: Impertio-Studio, за ліцензією MIT. Ви платите лише своєму постачальнику ШІ за використані токени.

Що таке навички ШІ?

Навичка ШІ — це багаторазовий набір інструкцій, який навчає модель ШІ виконувати одне конкретне завдання. Він відповідає відкритому формату Agent Skills: файл SKILL.md із назвою та описом, а також скрипти, шаблони чи довідкові файли, які можуть знадобитися моделі. Модель читає інструкції лише тоді, коли ваш запит відповідає навичці, тому встановлена навичка нічого не коштує, доки її не використано.

Чим навички ШІ відрізняються від плагінів або серверів MCP?

Плагін або сервер MCP надає моделі нові інструменти для виклику — код, який десь виконується й повертає результат. Натомість навичка ШІ надає моделі знання та порядок дій: як підійти до завдання, яких кроків дотримуватися та яким має бути якісний результат. Навички — це звичайний Markdown, тож їм не потрібні ні сервер, ні ключ API, ні середовище виконання, і вони працюють із будь-якою моделлю.

Усі

Створіть власний ШІ-простір уже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇