mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
material.remove_material and copy_material to handle ifc2x3 props
This commit is contained in:
@@ -48,11 +48,23 @@ def copy_material(file, material=None) -> None:
|
|||||||
if inverse.is_a("IfcMaterialProperties"):
|
if inverse.is_a("IfcMaterialProperties"):
|
||||||
# Properties must not be shared between objects for convenience of authoring
|
# Properties must not be shared between objects for convenience of authoring
|
||||||
inverse = ifcopenshell.util.element.copy(file, inverse)
|
inverse = ifcopenshell.util.element.copy(file, inverse)
|
||||||
properties = []
|
|
||||||
for pset in inverse.Properties:
|
|
||||||
properties.append(ifcopenshell.util.element.copy_deep(file, pset))
|
|
||||||
inverse.Properties = properties
|
|
||||||
inverse.Material = new
|
inverse.Material = new
|
||||||
|
|
||||||
|
props_attribute = "Properties"
|
||||||
|
if file.schema == "IFC2X3":
|
||||||
|
if not inverse.is_a("IfcExtendedMaterialProperties"):
|
||||||
|
continue
|
||||||
|
props_attribute = "ExtendedProperties"
|
||||||
|
|
||||||
|
props = getattr(inverse, props_attribute)
|
||||||
|
if not props:
|
||||||
|
continue
|
||||||
|
|
||||||
|
copied_props = []
|
||||||
|
for pset in props:
|
||||||
|
copied_props.append(ifcopenshell.util.element.copy_deep(file, pset))
|
||||||
|
setattr(inverse, props_attribute, copied_props)
|
||||||
|
|
||||||
elif inverse.is_a("IfcMaterialDefinitionRepresentation"):
|
elif inverse.is_a("IfcMaterialDefinitionRepresentation"):
|
||||||
inverse = ifcopenshell.util.element.copy_deep(
|
inverse = ifcopenshell.util.element.copy_deep(
|
||||||
file, inverse, exclude=["IfcRepresentationContext", "IfcMaterial"]
|
file, inverse, exclude=["IfcRepresentationContext", "IfcMaterial"]
|
||||||
|
|||||||
@@ -62,7 +62,13 @@ def remove_material(file, material=None) -> None:
|
|||||||
if history:
|
if history:
|
||||||
ifcopenshell.util.element.remove_deep2(file, history)
|
ifcopenshell.util.element.remove_deep2(file, history)
|
||||||
elif inverse.is_a("IfcMaterialProperties"):
|
elif inverse.is_a("IfcMaterialProperties"):
|
||||||
for prop in inverse.Properties or []:
|
if file.schema != "IFC2X3":
|
||||||
|
props = inverse.Properties
|
||||||
|
else:
|
||||||
|
# only IfcExtendedMaterialProperties have properties in IFC2X3
|
||||||
|
props = getattr(inverse, "ExtendedProperties", None)
|
||||||
|
props = props or []
|
||||||
|
for prop in props:
|
||||||
file.remove(prop)
|
file.remove(prop)
|
||||||
file.remove(inverse)
|
file.remove(inverse)
|
||||||
elif inverse.is_a("IfcMaterialDefinitionRepresentation"):
|
elif inverse.is_a("IfcMaterialDefinitionRepresentation"):
|
||||||
|
|||||||
Reference in New Issue
Block a user