mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
1) BBIM was failing to unregister properly. 2) Failed to link materials on load. 3) Failed to purge IFC file. 4) Error changing style name
This commit is contained in:
@@ -283,7 +283,6 @@ def unregister():
|
||||
del bpy.types.Scene.BIMProperties
|
||||
del bpy.types.Collection.BIMCollectionProperties
|
||||
del bpy.types.Object.BIMObjectProperties
|
||||
del bpy.types.Material.BIMObjectProperties
|
||||
del bpy.types.Material.BIMMaterialProperties
|
||||
del bpy.types.Mesh.BIMMeshProperties
|
||||
del bpy.types.Curve.BIMMeshProperties
|
||||
|
||||
@@ -205,19 +205,24 @@ class IfcStore:
|
||||
def relink_object(obj: IFC_CONNECTED_TYPE) -> None:
|
||||
if not obj:
|
||||
return
|
||||
if obj.BIMObjectProperties.ifc_definition_id:
|
||||
if isinstance(obj, bpy.types.Object):
|
||||
ifc_definition_id = obj.BIMObjectProperties.ifc_definition_id
|
||||
if not ifc_definition_id:
|
||||
return
|
||||
try:
|
||||
element = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||
except:
|
||||
element = IfcStore.get_file().by_id(ifc_definition_id)
|
||||
except RuntimeError:
|
||||
return
|
||||
data = OperationData(id=element.id(), obj=obj.name)
|
||||
if hasattr(element, "GlobalId"):
|
||||
data["guid"] = element.GlobalId
|
||||
IfcStore.commit_link_element(data)
|
||||
if hasattr(obj, "BIMMaterialProperties") and obj.BIMMaterialProperties.ifc_style_id:
|
||||
return
|
||||
else: # bpy.types.Material
|
||||
ifc_definition_id = obj.BIMMaterialProperties.ifc_style_id
|
||||
try:
|
||||
element = IfcStore.get_file().by_id(obj.BIMMaterialProperties.ifc_style_id)
|
||||
except:
|
||||
element = IfcStore.get_file().by_id(ifc_definition_id)
|
||||
except RuntimeError:
|
||||
return
|
||||
data = OperationData(id=element.id(), obj=obj.name)
|
||||
IfcStore.commit_link_element(data)
|
||||
|
||||
@@ -90,12 +90,11 @@ class ConvertToBlender(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
for obj in bpy.data.objects:
|
||||
if obj.type in {"MESH", "EMPTY"}:
|
||||
obj.BIMObjectProperties.ifc_definition_id = 0
|
||||
tool.Ifc.unlink(obj=obj)
|
||||
if obj.data:
|
||||
obj.data.BIMMeshProperties.ifc_definition_id = 0
|
||||
for material in bpy.data.materials:
|
||||
material.BIMObjectProperties.ifc_definition_id = 0
|
||||
material.BIMMaterialProperties.ifc_style_id = 0
|
||||
tool.Ifc.unlink(obj=material)
|
||||
context.scene.BIMProperties.ifc_file = ""
|
||||
context.scene.BIMDebugProperties.attributes.clear()
|
||||
IfcStore.purge()
|
||||
|
||||
@@ -35,16 +35,10 @@ def sync_name(usecase_path, ifc_file, settings):
|
||||
return
|
||||
if isinstance(obj, bpy.types.Object):
|
||||
new_name = "{}/{}".format(element.is_a(), settings["attributes"]["Name"] or "Unnamed")
|
||||
collection = obj.BIMObjectProperties.collection
|
||||
if collection:
|
||||
collection.name = new_name
|
||||
elif isinstance(obj, bpy.types.Material):
|
||||
new_name = settings["attributes"]["Name"] or "Unnamed"
|
||||
material = tool.Ifc.get_entity(obj)
|
||||
if material and material != element:
|
||||
material.Name = new_name
|
||||
style = tool.Style.get_style(obj)
|
||||
if style and style != element:
|
||||
style.Name = new_name
|
||||
collection = obj.BIMObjectProperties.collection
|
||||
if collection:
|
||||
collection.name = new_name
|
||||
obj.name = new_name
|
||||
blenderbim.bim.handler.refresh_ui_data()
|
||||
|
||||
Reference in New Issue
Block a user