mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 20:50:02 +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):
|
def _execute(self, context):
|
||||||
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)
|
tool.Material.duplicate_material(material)
|
||||||
|
|
||||||
if not new.is_a("IfcMaterialList"):
|
|
||||||
name = new[0] + " Copy"
|
|
||||||
new[0] = name
|
|
||||||
|
|
||||||
material_prop_purge()
|
material_prop_purge()
|
||||||
bpy.ops.bim.load_materials()
|
bpy.ops.bim.load_materials()
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,19 @@ class Material(blenderbim.core.tool.Material):
|
|||||||
def disable_editing_materials(cls) -> None:
|
def disable_editing_materials(cls) -> None:
|
||||||
bpy.context.scene.BIMMaterialProperties.is_editing = False
|
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
|
@classmethod
|
||||||
def enable_editing_materials(cls) -> None:
|
def enable_editing_materials(cls) -> None:
|
||||||
bpy.context.scene.BIMMaterialProperties.is_editing = True
|
bpy.context.scene.BIMMaterialProperties.is_editing = True
|
||||||
|
|||||||
@@ -85,5 +85,6 @@ class Profile(blenderbim.core.tool.Profile):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def duplicate_profile(cls, profile: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
|
def duplicate_profile(cls, profile: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
|
||||||
new_profile = ifcopenshell.util.element.copy_deep(tool.Ifc.get(), profile)
|
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"
|
new_profile.ProfileName = profile.ProfileName + "_copy"
|
||||||
return new_profile
|
return new_profile
|
||||||
|
|||||||
Reference in New Issue
Block a user