mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix #1546. New feature to copy the material of the active object to selected objects.
This commit is contained in:
@@ -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.
|
||||
Reference in New Issue
Block a user