Example #1
0
 def _execute(self, context):
     obj = bpy.data.objects.get(
         self.obj) if self.obj else context.active_object
     self.file = IfcStore.get_file()
     ifcopenshell.api.run("material.remove_layer", self.file,
                          **{"layer": self.file.by_id(self.layer)})
     Data.load_layers()
     return {"FINISHED"}
Example #2
0
 def _execute(self, context):
     obj = bpy.data.objects.get(
         self.obj) if self.obj else context.active_object
     self.file = IfcStore.get_file()
     ifcopenshell.api.run(
         "material.add_layer",
         self.file,
         **{
             "layer_set":
             self.file.by_id(self.layer_set),
             "material":
             self.file.by_id(int(obj.BIMObjectMaterialProperties.material)),
         },
     )
     Data.load_layers()
     return {"FINISHED"}
Example #3
0
 def _execute(self, context):
     obj = bpy.data.objects.get(
         self.obj) if self.obj else context.active_object
     self.file = IfcStore.get_file()
     material_set = self.file.by_id(self.material_set)
     ifcopenshell.api.run(
         "material.reorder_set_item",
         self.file,
         **{
             "material_set": material_set,
             "old_index": self.old_index,
             "new_index": self.new_index,
         },
     )
     if material_set.is_a("IfcMaterialConstituentSet"):
         Data.load_constituents()
     elif material_set.is_a("IfcMaterialLayerSet"):
         Data.load_layers()
     elif material_set.is_a("IfcMaterialProfileSet"):
         Data.load_profiles()
         ProfileData.load(self.file)
     elif material_set.is_a("IfcMaterialList"):
         Data.load_lists()
     return {"FINISHED"}
Example #4
0
    def _execute(self, context):
        obj = bpy.data.objects.get(
            self.obj) if self.obj else context.active_object
        self.file = IfcStore.get_file()
        props = obj.BIMObjectMaterialProperties
        product_data = Data.products[obj.BIMObjectProperties.ifc_definition_id]

        attributes = blenderbim.bim.helper.export_attributes(
            props.material_set_item_attributes)

        if product_data["type"] == "IfcMaterialConstituentSet":
            ifcopenshell.api.run(
                "material.edit_constituent",
                self.file,
                **{
                    "constituent":
                    self.file.by_id(self.material_set_item),
                    "attributes":
                    attributes,
                    "material":
                    self.file.by_id(
                        int(obj.BIMObjectMaterialProperties.
                            material_set_item_material)),
                },
            )
            Data.load_constituents()
        elif product_data["type"] == "IfcMaterialLayerSet" or product_data[
                "type"] == "IfcMaterialLayerSetUsage":
            ifcopenshell.api.run(
                "material.edit_layer",
                self.file,
                **{
                    "layer":
                    self.file.by_id(self.material_set_item),
                    "attributes":
                    attributes,
                    "material":
                    self.file.by_id(
                        int(obj.BIMObjectMaterialProperties.
                            material_set_item_material)),
                },
            )
            Data.load_layers()
        elif product_data["type"] == "IfcMaterialProfileSet" or product_data[
                "type"] == "IfcMaterialProfileSetUsage":
            profile_attributes = blenderbim.bim.helper.export_attributes(
                props.material_set_item_profile_attributes)
            ifcopenshell.api.run(
                "material.edit_profile",
                self.file,
                **{
                    "profile":
                    self.file.by_id(self.material_set_item),
                    "attributes":
                    attributes,
                    "profile_attributes":
                    profile_attributes,
                    "material":
                    self.file.by_id(
                        int(obj.BIMObjectMaterialProperties.
                            material_set_item_material)),
                },
            )
            Data.load_profiles()
            ProfileData.load(self.file)
        else:
            pass

        bpy.ops.bim.disable_editing_material_set_item(obj=obj.name)
        return {"FINISHED"}
Example #5
0
    def _execute(self, context):
        self.file = IfcStore.get_file()
        obj = bpy.data.objects.get(
            self.obj) if self.obj else context.active_object
        props = obj.BIMObjectMaterialProperties
        product_data = Data.products[obj.BIMObjectProperties.ifc_definition_id]

        if product_data["type"] == "IfcMaterial":
            bpy.ops.bim.unassign_material(obj=obj.name)
            bpy.ops.bim.assign_material(obj=obj.name,
                                        material_type="IfcMaterial")
            Data.load(IfcStore.get_file(),
                      obj.BIMObjectProperties.ifc_definition_id)
            bpy.ops.bim.disable_editing_assigned_material(obj=obj.name)
            return {"FINISHED"}

        material_set = self.file.by_id(self.material_set)
        attributes = blenderbim.bim.helper.export_attributes(
            props.material_set_attributes)
        ifcopenshell.api.run(
            "material.edit_assigned_material",
            self.file,
            **{
                "element": material_set,
                "attributes": attributes
            },
        )
        Data.load(IfcStore.get_file(),
                  obj.BIMObjectProperties.ifc_definition_id)

        if self.material_set_usage:
            material_set_usage = self.file.by_id(self.material_set_usage)
            attributes = blenderbim.bim.helper.export_attributes(
                props.material_set_usage_attributes)
            if material_set_usage.is_a("IfcMaterialLayerSetUsage"):
                ifcopenshell.api.run(
                    "material.edit_layer_usage",
                    self.file,
                    **{
                        "usage": material_set_usage,
                        "attributes": attributes
                    },
                )
                Data.load_layer_usages()
            elif material_set_usage.is_a("IfcMaterialProfileSetUsage"):
                if attributes.get("CardinalPoint", None):
                    attributes["CardinalPoint"] = int(
                        attributes["CardinalPoint"])
                ifcopenshell.api.run(
                    "material.edit_profile_usage",
                    self.file,
                    **{
                        "usage": material_set_usage,
                        "attributes": attributes
                    },
                )
                Data.load_profile_usages()

        if material_set.is_a("IfcMaterialConstituentSet"):
            Data.load_constituents()
        elif material_set.is_a("IfcMaterialLayerSet"):
            Data.load_layers()
        elif material_set.is_a("IfcMaterialProfileSet"):
            Data.load_profiles()
        bpy.ops.bim.disable_editing_assigned_material(obj=obj.name)
        return {"FINISHED"}