diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index 0747c8d7d7..37aa0c1dab 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -71,6 +71,9 @@ if bpy is not None: operator.AddMaterialLayer, operator.RemoveMaterialLayer, operator.MoveMaterialLayer, + operator.AddMaterialConstituent, + operator.RemoveMaterialConstituent, + operator.MoveMaterialConstituent, operator.AddConstraint, operator.RemoveConstraint, operator.AssignConstraint, @@ -210,6 +213,8 @@ if bpy is not None: operator.UpdateIfcRepresentation, prop.StrProperty, prop.MaterialLayer, + prop.MaterialConstituent, + prop.MaterialSet, prop.Variable, prop.Role, prop.Address, diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index e0e3d15d5c..79d94930e9 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -3609,7 +3609,7 @@ class ConvertLocalToGlobal(bpy.types.Operator): float(bpy.context.scene.MapConversion.orthogonal_height), float(bpy.context.scene.MapConversion.x_axis_abscissa), float(bpy.context.scene.MapConversion.x_axis_ordinate), - scale + scale, ) print("Coordinates:", results) bpy.context.scene.cursor.location = results @@ -3634,7 +3634,7 @@ class ConvertGlobalToLocal(bpy.types.Operator): float(bpy.context.scene.MapConversion.orthogonal_height), float(bpy.context.scene.MapConversion.x_axis_abscissa), float(bpy.context.scene.MapConversion.x_axis_ordinate), - scale + scale, ) print("Coordinates:", results) bpy.context.scene.cursor.location = results @@ -4124,7 +4124,7 @@ class AddMaterialLayer(bpy.types.Operator): bl_label = "Add Material Layer" def execute(self, context): - new = bpy.context.active_object.BIMObjectProperties.material_layers.add() + new = bpy.context.active_object.BIMObjectProperties.material_set.material_layers.add() new.material = bpy.data.materials[0] new.name = "Material Layer" return {"FINISHED"} @@ -4136,7 +4136,7 @@ class RemoveMaterialLayer(bpy.types.Operator): index: bpy.props.IntProperty() def execute(self, context): - bpy.context.active_object.BIMObjectProperties.material_layers.remove(self.index) + bpy.context.active_object.BIMObjectProperties.material_set.material_layers.remove(self.index) return {"FINISHED"} @@ -4146,7 +4146,7 @@ class MoveMaterialLayer(bpy.types.Operator): direction: bpy.props.StringProperty() def execute(self, context): - props = bpy.context.active_object.BIMObjectProperties + props = bpy.context.active_object.BIMObjectProperties.material_set index = props.active_material_layer_index if self.direction == "UP" and index - 1 >= 0: props.material_layers.move(index, index - 1) @@ -4157,6 +4157,44 @@ class MoveMaterialLayer(bpy.types.Operator): return {"FINISHED"} +class AddMaterialConstituent(bpy.types.Operator): + bl_idname = "bim.add_material_constituent" + bl_label = "Add Material Constituent" + + def execute(self, context): + new = bpy.context.active_object.BIMObjectProperties.material_set.material_constituents.add() + new.material = bpy.data.materials[0] + new.name = "Material Constituent" + return {"FINISHED"} + + +class RemoveMaterialConstituent(bpy.types.Operator): + bl_idname = "bim.remove_material_constituent" + bl_label = "Remove Material Constituent" + index: bpy.props.IntProperty() + + def execute(self, context): + bpy.context.active_object.BIMObjectProperties.material_set.material_constituents.remove(self.index) + return {"FINISHED"} + + +class MoveMaterialConstituent(bpy.types.Operator): + bl_idname = "bim.move_material_constituent" + bl_label = "Move Material Constituent" + direction: bpy.props.StringProperty() + + def execute(self, context): + props = bpy.context.active_object.BIMObjectProperties.material_set + index = props.active_material_constituent_index + if self.direction == "UP" and index - 1 >= 0: + props.material_constituents.move(index, index - 1) + props.active_material_constituent_index = index - 1 + elif self.direction == "DOWN" and index + 1 < len(props.material_constituents): + props.material_constituents.move(index, index + 1) + props.active_material_constituent_index = index + 1 + return {"FINISHED"} + + class SelectScheduleFile(bpy.types.Operator): bl_idname = "bim.select_schedule_file" bl_label = "Select Documentation IFC File" @@ -4220,7 +4258,7 @@ class SetNorthOffset(bpy.types.Operator): bl_label = "Set North Offset" def execute(self, context): - context.scene.sun_pos_properties.north_offset = - radians( + context.scene.sun_pos_properties.north_offset = -radians( ifcopenshell.util.geolocation.xy2angle( float(bpy.context.scene.MapConversion.x_axis_abscissa), float(bpy.context.scene.MapConversion.x_axis_ordinate), diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 76660ae2f5..9fbf174ad9 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -575,6 +575,23 @@ class MaterialLayer(PropertyGroup): priority: IntProperty(name="Priority") +class MaterialConstituent(PropertyGroup): + name: StringProperty(name="Name") + description: StringProperty(name="Description") + material: PointerProperty(name="Material", type=bpy.types.Material) + fraction: FloatProperty(name="Fraction") + category: StringProperty(name="Category") + + +class MaterialSet(PropertyGroup): + name: StringProperty(name="Name") + description: StringProperty(name="Description") + active_material_layer_index: IntProperty(name="Active Material Layer Index") + material_layers: CollectionProperty(name="Material Layers", type=MaterialLayer) + active_material_constituent_index: IntProperty(name="Active Material Constituent Index") + material_constituents: CollectionProperty(name="Material Constituents", type=MaterialConstituent) + + class Drawing(PropertyGroup): name: StringProperty(name="Name", update=updateDrawingName) camera: PointerProperty(name="Camera", type=bpy.types.Object) @@ -1636,8 +1653,7 @@ class BIMObjectProperties(PropertyGroup): classifications: CollectionProperty(name="Classifications", type=ClassificationReference) material_type: EnumProperty(items=getMaterialTypes, name="Material Type") material: PointerProperty(name="Material", type=bpy.types.Material) - material_layers: CollectionProperty(name="Material Layers", type=MaterialLayer) - active_material_layer_index: IntProperty(name="Active Material Layer Index") + material_set: PointerProperty(name="Material Set", type=MaterialSet) pset_name: EnumProperty(items=getPsetNames, name="Pset Name") qto_name: EnumProperty(items=getQtoNames, name="Qto Name") has_boundary_condition: BoolProperty(name="Has Boundary Condition") diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 6348f4863f..40567c42f3 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -126,19 +126,28 @@ class BIM_PT_object_material(Panel): if props.material_type == "IfcMaterial": row = layout.row() row.prop(props, "material") - elif props.material_type == "IfcMaterialLayerSet": + else: + set_props = props.material_set row = layout.row() + row.prop(set_props, "name", text="Name") + row = layout.row() + row.prop(set_props, "description", text="Description") + row = layout.row() + + if props.material_type == "IfcMaterialLayerSet": row.template_list( - "MATERIAL_UL_matslots", "", props, "material_layers", props, "active_material_layer_index" + "MATERIAL_UL_matslots", "", set_props, "material_layers", set_props, "active_material_layer_index" ) col = row.column(align=True) col.operator("bim.add_material_layer", icon="ADD", text="") - col.operator("bim.remove_material_layer", icon="REMOVE", text="").index = props.active_material_layer_index + col.operator( + "bim.remove_material_layer", icon="REMOVE", text="" + ).index = set_props.active_material_layer_index col.operator("bim.move_material_layer", icon="TRIA_UP", text="").direction = "UP" col.operator("bim.move_material_layer", icon="TRIA_DOWN", text="").direction = "DOWN" - if props.active_material_layer_index < len(props.material_layers): - material = props.material_layers[props.active_material_layer_index] + if set_props.active_material_layer_index < len(set_props.material_layers): + material = set_props.material_layers[set_props.active_material_layer_index] row = layout.row() row.prop(material, "material") row = layout.row() @@ -154,6 +163,35 @@ class BIM_PT_object_material(Panel): row.prop(material, "layer_thickness") row = layout.row() row.prop(material, "priority") + elif props.material_type == "IfcMaterialConstituentSet": + row.template_list( + "MATERIAL_UL_matslots", + "", + set_props, + "material_constituents", + set_props, + "active_material_constituent_index", + ) + col = row.column(align=True) + col.operator("bim.add_material_constituent", icon="ADD", text="") + col.operator( + "bim.remove_material_constituent", icon="REMOVE", text="" + ).index = set_props.active_material_constituent_index + col.operator("bim.move_material_constituent", icon="TRIA_UP", text="").direction = "UP" + col.operator("bim.move_material_constituent", icon="TRIA_DOWN", text="").direction = "DOWN" + + if set_props.active_material_constituent_index < len(set_props.material_constituents): + material = set_props.material_constituents[set_props.active_material_constituent_index] + row = layout.row() + row.prop(material, "material") + row = layout.row() + row.prop(material, "name") + row = layout.row() + row.prop(material, "description") + row = layout.row() + row.prop(material, "fraction") + row = layout.row() + row.prop(material, "category") class BIM_PT_object_psets(Panel):