WIP implement add/remove material. See #1222.

This commit is contained in:
Dion Moult
2021-01-26 11:45:58 +11:00
parent 8618befa0f
commit 276dc0d894
6 changed files with 88 additions and 7 deletions
@@ -1,4 +1,6 @@
import bpy
import blenderbim.bim.module.material.add_material as add_material
import blenderbim.bim.module.material.remove_material as remove_material
import blenderbim.bim.module.material.assign_material as assign_material
import blenderbim.bim.module.material.unassign_material as unassign_material
import blenderbim.bim.module.material.add_constituent as add_constituent
@@ -13,6 +15,34 @@ from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.material.data import Data
class AddMaterial(bpy.types.Operator):
bl_idname = "bim.add_material"
bl_label = "Add Material"
obj: bpy.props.StringProperty()
def execute(self, context):
obj = bpy.data.materials.get(self.obj) if self.obj else bpy.context.active_object.active_material
self.file = IfcStore.get_file()
result = add_material.Usecase(self.file, {"Name": obj.name}).execute()
obj.BIMObjectProperties.ifc_definition_id = result.id()
return {"FINISHED"}
class RemoveMaterial(bpy.types.Operator):
bl_idname = "bim.remove_material"
bl_label = "Remove Material"
obj: bpy.props.StringProperty()
def execute(self, context):
obj = bpy.data.materials.get(self.obj) if self.obj else bpy.context.active_object.active_material
self.file = IfcStore.get_file()
result = remove_material.Usecase(
self.file, {"material": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)}
).execute()
obj.BIMObjectProperties.ifc_definition_id = 0
return {"FINISHED"}
class AssignMaterial(bpy.types.Operator):
bl_idname = "bim.assign_material"
bl_label = "Assign Material"