Fix bug duplicating and editing materials #4843

It was giving errors trying since ifc materials are no longer to connect to the blender materials.
This commit is contained in:
Andrej730
2024-07-05 13:49:45 +05:00
parent 79f96d22a5
commit fdaf059c60
4 changed files with 0 additions and 21 deletions
@@ -148,15 +148,9 @@ class DuplicateMaterial(bpy.types.Operator, tool.Ifc.Operator):
material = tool.Ifc.get().by_id(self.material)
new = tool.Ifc.run("material.copy_material", material=material)
blender_material = tool.Ifc.get_object(material)
new_blender = blender_material.copy()
new_blender.use_fake_user = True
tool.Ifc.link(new, new_blender)
if not new.is_a("IfcMaterialList"):
name = new[0] + " Copy"
new[0] = name
new_blender.name = name
material_prop_purge()
bpy.ops.bim.load_materials()
@@ -88,7 +88,6 @@ def enable_editing_material(material_tool: tool.Material, material: ifcopenshell
def edit_material(ifc: tool.Ifc, material_tool: tool.Material, material: ifcopenshell.entity_instance) -> None:
attributes = material_tool.get_material_attributes()
ifc.run("material.edit_material", material=material, attributes=attributes)
material_tool.sync_blender_material_name(material)
material_tool.disable_editing_material()
material_type = material_tool.get_active_material_type()
material_tool.import_material_definitions(material_type)
-1
View File
@@ -507,7 +507,6 @@ class Material:
def is_material_used_in_sets(cls, material): pass
def load_material_attributes(cls, material): pass
def replace_material_with_material_profile(cls, element): pass
def sync_blender_material_name(cls, material): pass
@interface
@@ -263,19 +263,6 @@ class Material(blenderbim.core.tool.Material):
objects = [tool.Ifc.get_object(e) for e in elements]
tool.Geometry.reload_representation(objects)
@classmethod
def sync_blender_material_name(cls, material: ifcopenshell.entity_instance) -> None:
name = material.Name or "Unnamed"
obj = tool.Ifc.get_object(material)
if obj:
obj.name = name
style = tool.Style.get_style(obj)
if style:
style.Name = name
obj = tool.Ifc.get_object(style)
if obj:
obj.name = name
@classmethod
def get_style(cls, material: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
for material_representation in material.HasRepresentation: