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