mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 00:07:53 +00:00
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:
@@ -148,15 +148,9 @@ class DuplicateMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
material = tool.Ifc.get().by_id(self.material)
|
material = tool.Ifc.get().by_id(self.material)
|
||||||
new = tool.Ifc.run("material.copy_material", material=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"):
|
if not new.is_a("IfcMaterialList"):
|
||||||
name = new[0] + " Copy"
|
name = new[0] + " Copy"
|
||||||
new[0] = name
|
new[0] = name
|
||||||
new_blender.name = name
|
|
||||||
|
|
||||||
material_prop_purge()
|
material_prop_purge()
|
||||||
bpy.ops.bim.load_materials()
|
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:
|
def edit_material(ifc: tool.Ifc, material_tool: tool.Material, material: ifcopenshell.entity_instance) -> None:
|
||||||
attributes = material_tool.get_material_attributes()
|
attributes = material_tool.get_material_attributes()
|
||||||
ifc.run("material.edit_material", material=material, attributes=attributes)
|
ifc.run("material.edit_material", material=material, attributes=attributes)
|
||||||
material_tool.sync_blender_material_name(material)
|
|
||||||
material_tool.disable_editing_material()
|
material_tool.disable_editing_material()
|
||||||
material_type = material_tool.get_active_material_type()
|
material_type = material_tool.get_active_material_type()
|
||||||
material_tool.import_material_definitions(material_type)
|
material_tool.import_material_definitions(material_type)
|
||||||
|
|||||||
@@ -507,7 +507,6 @@ class Material:
|
|||||||
def is_material_used_in_sets(cls, material): pass
|
def is_material_used_in_sets(cls, material): pass
|
||||||
def load_material_attributes(cls, material): pass
|
def load_material_attributes(cls, material): pass
|
||||||
def replace_material_with_material_profile(cls, element): pass
|
def replace_material_with_material_profile(cls, element): pass
|
||||||
def sync_blender_material_name(cls, material): pass
|
|
||||||
|
|
||||||
|
|
||||||
@interface
|
@interface
|
||||||
|
|||||||
@@ -263,19 +263,6 @@ class Material(blenderbim.core.tool.Material):
|
|||||||
objects = [tool.Ifc.get_object(e) for e in elements]
|
objects = [tool.Ifc.get_object(e) for e in elements]
|
||||||
tool.Geometry.reload_representation(objects)
|
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
|
@classmethod
|
||||||
def get_style(cls, material: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
def get_style(cls, material: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
||||||
for material_representation in material.HasRepresentation:
|
for material_representation in material.HasRepresentation:
|
||||||
|
|||||||
Reference in New Issue
Block a user