mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
bim.duplicate_material to handle IfcMaterialLayerSets names
This commit is contained in:
@@ -146,12 +146,7 @@ class DuplicateMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
material = tool.Ifc.get().by_id(self.material)
|
||||
new = tool.Ifc.run("material.copy_material", material=material)
|
||||
|
||||
if not new.is_a("IfcMaterialList"):
|
||||
name = new[0] + " Copy"
|
||||
new[0] = name
|
||||
|
||||
tool.Material.duplicate_material(material)
|
||||
material_prop_purge()
|
||||
bpy.ops.bim.load_materials()
|
||||
|
||||
|
||||
@@ -38,6 +38,19 @@ class Material(blenderbim.core.tool.Material):
|
||||
def disable_editing_materials(cls) -> None:
|
||||
bpy.context.scene.BIMMaterialProperties.is_editing = False
|
||||
|
||||
@classmethod
|
||||
def duplicate_material(cls, material: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
|
||||
new = tool.Ifc.run("material.copy_material", material=material)
|
||||
|
||||
# Doesn't have a name.
|
||||
if new.is_a("IfcMaterialList"):
|
||||
return new
|
||||
|
||||
name_index = 1 if new.is_a("IfcMaterialLayerSet") else 0
|
||||
name = (new[name_index] or "Unnamed") + " Copy"
|
||||
new[name_index] = name
|
||||
return new
|
||||
|
||||
@classmethod
|
||||
def enable_editing_materials(cls) -> None:
|
||||
bpy.context.scene.BIMMaterialProperties.is_editing = True
|
||||
|
||||
@@ -85,5 +85,6 @@ class Profile(blenderbim.core.tool.Profile):
|
||||
@classmethod
|
||||
def duplicate_profile(cls, profile: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
|
||||
new_profile = ifcopenshell.util.element.copy_deep(tool.Ifc.get(), profile)
|
||||
# In UI unnamed profiles are not available, so we don't handle them.
|
||||
new_profile.ProfileName = profile.ProfileName + "_copy"
|
||||
return new_profile
|
||||
|
||||
Reference in New Issue
Block a user