mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
common method for setting up Blender listeners for objects
This commit is contained in:
@@ -274,12 +274,7 @@ class IfcStore:
|
||||
else:
|
||||
obj.BIMObjectProperties.ifc_definition_id = element.id()
|
||||
|
||||
bonsai.bim.handler.subscribe_to(obj, "name", bonsai.bim.handler.name_callback)
|
||||
|
||||
if isinstance(obj, bpy.types.Object):
|
||||
bonsai.bim.handler.subscribe_to(
|
||||
obj, "active_material_index", bonsai.bim.handler.active_material_index_callback
|
||||
)
|
||||
tool.Ifc.setup_listeners(obj)
|
||||
|
||||
if IfcStore.history:
|
||||
data = OperationData(id=element.id(), guid=getattr(element, "GlobalId", None), obj=obj.name)
|
||||
@@ -301,11 +296,7 @@ class IfcStore:
|
||||
IfcStore.id_map[data["id"]] = obj
|
||||
if "guid" in data:
|
||||
IfcStore.guid_map[data["guid"]] = obj
|
||||
bonsai.bim.handler.subscribe_to(obj, "name", bonsai.bim.handler.name_callback)
|
||||
if isinstance(obj, bpy.types.Object):
|
||||
bonsai.bim.handler.subscribe_to(
|
||||
obj, "active_material_index", bonsai.bim.handler.active_material_index_callback
|
||||
)
|
||||
tool.Ifc.setup_listeners(obj)
|
||||
# TODO Listeners are not re-registered. Does this cause nasty problems to debug later on?
|
||||
# TODO We're handling id_map and guid_map, but what about edited_objs? This might cause big problems.
|
||||
|
||||
|
||||
@@ -161,10 +161,7 @@ class Ifc(bonsai.core.tool.Ifc):
|
||||
if global_id:
|
||||
IfcStore.guid_map[global_id] = obj
|
||||
|
||||
bonsai.bim.handler.subscribe_to(obj, "name", bonsai.bim.handler.name_callback)
|
||||
bonsai.bim.handler.subscribe_to(
|
||||
obj, "active_material_index", bonsai.bim.handler.active_material_index_callback
|
||||
)
|
||||
cls.setup_listeners(obj)
|
||||
|
||||
for obj in bpy.data.materials:
|
||||
if obj.library:
|
||||
@@ -177,7 +174,15 @@ class Ifc(bonsai.core.tool.Ifc):
|
||||
continue
|
||||
|
||||
IfcStore.id_map[style.id()] = obj
|
||||
bonsai.bim.handler.subscribe_to(obj, "name", bonsai.bim.handler.name_callback)
|
||||
cls.setup_listeners(obj)
|
||||
|
||||
@classmethod
|
||||
def setup_listeners(cls, obj: IFC_CONNECTED_TYPE) -> None:
|
||||
if isinstance(obj, bpy.types.Object):
|
||||
bonsai.bim.handler.subscribe_to(
|
||||
obj, "active_material_index", bonsai.bim.handler.active_material_index_callback
|
||||
)
|
||||
bonsai.bim.handler.subscribe_to(obj, "name", bonsai.bim.handler.name_callback)
|
||||
|
||||
@classmethod
|
||||
def link(
|
||||
|
||||
Reference in New Issue
Block a user