mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
Assign / Unassign Material executes on all selected objects
This commit is contained in:
@@ -124,9 +124,12 @@ class AssignMaterial(bpy.types.Operator):
|
|||||||
return IfcStore.execute_ifc_operator(self, context)
|
return IfcStore.execute_ifc_operator(self, context)
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
|
||||||
material_type = self.material_type or obj.BIMObjectMaterialProperties.material_type
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
|
objs = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
||||||
|
for obj in objs:
|
||||||
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
|
continue
|
||||||
|
material_type = self.material_type or obj.BIMObjectMaterialProperties.material_type
|
||||||
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"material.assign_material",
|
"material.assign_material",
|
||||||
@@ -152,8 +155,11 @@ class UnassignMaterial(bpy.types.Operator):
|
|||||||
return IfcStore.execute_ifc_operator(self, context)
|
return IfcStore.execute_ifc_operator(self, context)
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
|
objs = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
||||||
|
for obj in objs:
|
||||||
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
|
continue
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"material.unassign_material",
|
"material.unassign_material",
|
||||||
self.file,
|
self.file,
|
||||||
|
|||||||
Reference in New Issue
Block a user