Fix #1546. New feature to copy the material of the active object to selected objects.

This commit is contained in:
Dion Moult
2021-08-08 20:13:24 +10:00
parent 18a52fd5f8
commit 2c66fbf1c4
6 changed files with 79 additions and 5 deletions
@@ -1,6 +1,3 @@
import ifcopenshell
class Usecase:
def __init__(self, file, **settings):
self.file = file
@@ -0,0 +1,30 @@
import ifcopenshell
import ifcopenshell.util.element
class Usecase:
def __init__(self, file, **settings):
self.file = file
self.settings = {"material": None, "element": None}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
ifcopenshell.api.run("material.unassign_material", self.file, product=self.settings["element"])
if self.settings["material"].is_a("IfcMaterial"):
ifcopenshell.api.run(
"material.assign_material",
self.file,
product=self.settings["element"],
type="IfcMaterial",
material=self.settings["material"],
)
# No other material type can be copied right now.
# 1. Material lists and constituents may have shape aspects and I
# haven't implemented it yet.
# 2. Material layer and profile sets implicitly define parametric
# geometry and we have no way of guaranteeing that this constraint is
# satisfied.
# 3. Material set usages follow an unofficial constraint that all
# instances must have a usage of their type's material set. We cannot
# guarantee that constraint.