示例#1
0
 def _execute(self, context):
     obj = bpy.data.materials.get(
         self.obj) if self.obj else context.active_object.active_material
     self.file = IfcStore.get_file()
     result = ifcopenshell.api.run("material.add_material", self.file,
                                   **{"name": obj.name})
     IfcStore.link_element(result, obj)
     if obj.BIMMaterialProperties.ifc_style_id:
         context = ifcopenshell.util.representation.get_context(
             self.file, "Model", "Body", "MODEL_VIEW")
         if context:
             ifcopenshell.api.run(
                 "style.assign_material_style",
                 self.file,
                 **{
                     "material":
                     result,
                     "style":
                     self.file.by_id(
                         obj.BIMMaterialProperties.ifc_style_id),
                     "context":
                     context,
                 },
             )
     Data.load(IfcStore.get_file())
     material_prop_purge()
     return {"FINISHED"}
示例#2
0
    def create_wall(self):
        verts = [
            Vector((0, self.width, 0)),
            Vector((0, 0, 0)),
            Vector((0, self.width, self.height)),
            Vector((0, 0, self.height)),
            Vector((self.length, self.width, 0)),
            Vector((self.length, 0, 0)),
            Vector((self.length, self.width, self.height)),
            Vector((self.length, 0, self.height)),
        ]
        faces = [
            [1, 3, 2, 0],
            [4, 6, 7, 5],
            [1, 0, 4, 5],
            [3, 7, 6, 2],
            [0, 2, 6, 4],
            [1, 5, 7, 3],
        ]
        mesh = bpy.data.meshes.new(name="Wall")
        mesh.from_pydata(verts, [], faces)

        ifc_classes = ifcopenshell.util.type.get_applicable_entities(
            self.relating_type.is_a(), self.file.schema)
        # Standard cases are deprecated, so let's cull them
        ifc_class = [c for c in ifc_classes if "StandardCase" not in c][0]

        obj = bpy.data.objects.new(
            tool.Model.generate_occurrence_name(self.relating_type, ifc_class),
            mesh)
        obj.location = self.location
        obj.rotation_euler[2] = self.rotation
        if self.collection_obj and self.collection_obj.BIMObjectProperties.ifc_definition_id:
            obj.location[2] = self.collection_obj.location[2]
        self.collection.objects.link(obj)

        bpy.ops.bim.assign_class(
            obj=obj.name,
            ifc_class=ifc_class,
            ifc_representation_class=
            "IfcExtrudedAreaSolid/IfcArbitraryClosedProfileDef",
        )

        blenderbim.core.type.assign_type(tool.Ifc,
                                         tool.Type,
                                         element=tool.Ifc.get_entity(obj),
                                         type=self.relating_type)
        element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
        pset = ifcopenshell.api.run("pset.add_pset",
                                    self.file,
                                    product=element,
                                    name="EPset_Parametric")
        ifcopenshell.api.run("pset.edit_pset",
                             self.file,
                             pset=pset,
                             properties={"Engine": "BlenderBIM.DumbLayer2"})
        MaterialData.load(self.file)
        obj.select_set(True)
        return obj
示例#3
0
    def create_slab(self):
        verts = [
            Vector((0, 0, 0)),
            Vector((0, self.width, 0)),
            Vector((self.length, self.width, 0)),
            Vector((self.length, 0, 0)),
        ]
        edges = []
        faces = [[0, 3, 2, 1]]

        ifc_classes = ifcopenshell.util.type.get_applicable_entities(
            self.relating_type.is_a(), self.file.schema)
        # Standard cases are deprecated, so let's cull them
        ifc_class = [c for c in ifc_classes if "StandardCase" not in c][0]

        mesh = bpy.data.meshes.new(name="Dumb Slab")
        mesh.from_pydata(verts, edges, faces)
        obj = bpy.data.objects.new(
            tool.Model.generate_occurrence_name(self.relating_type, ifc_class),
            mesh)
        modifier = obj.modifiers.new("Slab Depth", "SOLIDIFY")
        modifier.use_even_offset = True
        modifier.offset = 1
        modifier.thickness = self.depth

        obj.location = self.location
        if self.collection_obj and self.collection_obj.BIMObjectProperties.ifc_definition_id:
            obj.location[2] = self.collection_obj.location[2] - self.depth
        else:
            obj.location[2] -= self.depth
        self.collection.objects.link(obj)
        bpy.ops.bim.assign_class(
            obj=obj.name,
            ifc_class=ifc_class,
            ifc_representation_class=
            "IfcExtrudedAreaSolid/IfcArbitraryProfileDefWithVoids",
        )
        blenderbim.core.type.assign_type(tool.Ifc,
                                         tool.Type,
                                         element=tool.Ifc.get_entity(obj),
                                         type=self.relating_type)
        element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
        pset = ifcopenshell.api.run("pset.add_pset",
                                    self.file,
                                    product=element,
                                    name="EPset_Parametric")
        ifcopenshell.api.run("pset.edit_pset",
                             self.file,
                             pset=pset,
                             properties={"Engine": "BlenderBIM.DumbLayer3"})
        MaterialData.load(self.file)
        obj.select_set(True)
        return obj
示例#4
0
 def _execute(self, context):
     obj = bpy.data.materials.get(
         self.obj) if self.obj else context.active_object.active_material
     self.file = IfcStore.get_file()
     result = ifcopenshell.api.run(
         "material.remove_material",
         self.file,
         **{
             "material":
             self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
         },
     )
     obj.BIMObjectProperties.ifc_definition_id = 0
     Data.load(IfcStore.get_file())
     return {"FINISHED"}
示例#5
0
 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()
     element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
     ifcopenshell.api.run(
         "material.assign_material",
         self.file,
         **{
             "product":
             element,
             "type":
             material_type,
             "material":
             self.file.by_id(int(obj.BIMObjectMaterialProperties.material)),
         },
     )
     Data.load(IfcStore.get_file())
     Data.load(IfcStore.get_file(),
               obj.BIMObjectProperties.ifc_definition_id)
     return {"FINISHED"}
示例#6
0
 def _execute(self, context):
     self.file = IfcStore.get_file()
     material = ifcopenshell.util.element.get_material(
         self.file.by_id(
             context.active_object.BIMObjectProperties.ifc_definition_id))
     for obj in context.selected_objects:
         if obj == context.active_object:
             continue
         if not obj.BIMObjectProperties.ifc_definition_id:
             continue
         ifcopenshell.api.run(
             "material.copy_material",
             self.file,
             **{
                 "material":
                 material,
                 "element":
                 self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
             },
         )
         Data.load(self.file, obj.BIMObjectProperties.ifc_definition_id)
         self.set_default_material(obj, material)
     return {"FINISHED"}
示例#7
0
 def _execute(self, context):
     core.add_default_material(tool.Ifc, tool.Material)
     Data.load(IfcStore.get_file())
示例#8
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"}
示例#9
0
    def draw(self, context):
        self.file = IfcStore.get_file()
        self.oprops = context.active_object.BIMObjectProperties
        self.props = context.active_object.BIMObjectMaterialProperties
        if not Data.is_loaded:
            Data.load(IfcStore.get_file())
        if self.oprops.ifc_definition_id not in Data.products:
            Data.load(IfcStore.get_file(), self.oprops.ifc_definition_id)
        if not ProfileData.is_loaded:
            ProfileData.load(self.file)
        self.product_data = Data.products[self.oprops.ifc_definition_id]

        if not Data.materials:
            row = self.layout.row(align=True)
            row.label(text="No Materials Available")
            row.operator("bim.add_default_material", icon="ADD", text="")
            return

        if self.product_data:
            if self.product_data["type"] == "IfcMaterialConstituentSet":
                self.material_set_id = self.product_data["id"]
                self.material_set_data = Data.constituent_sets[self.material_set_id]
                self.set_items = self.material_set_data["MaterialConstituents"] or []
                self.set_data = Data.constituents
                self.set_item_name = "constituent"
            elif self.product_data["type"] == "IfcMaterialLayerSet":
                self.material_set_id = self.product_data["id"]
                self.material_set_data = Data.layer_sets[self.material_set_id]
                self.set_items = self.material_set_data["MaterialLayers"] or []
                self.set_data = Data.layers
                self.set_item_name = "layer"
            elif self.product_data["type"] == "IfcMaterialLayerSetUsage":
                self.material_set_usage = Data.layer_set_usages[self.product_data["id"]]
                self.material_set_id = self.material_set_usage["ForLayerSet"]
                self.material_set_data = Data.layer_sets[self.material_set_id]
                self.set_items = self.material_set_data["MaterialLayers"] or []
                self.set_data = Data.layers
                self.set_item_name = "layer"
            elif self.product_data["type"] == "IfcMaterialProfileSet":
                self.material_set_id = self.product_data["id"]
                self.material_set_data = Data.profile_sets[self.material_set_id]
                self.set_items = self.material_set_data["MaterialProfiles"] or []
                self.set_data = Data.profiles
                self.set_item_name = "profile"
            elif self.product_data["type"] == "IfcMaterialProfileSetUsage":
                self.material_set_usage = Data.profile_set_usages[self.product_data["id"]]
                self.material_set_id = self.material_set_usage["ForProfileSet"]
                self.material_set_data = Data.profile_sets[self.material_set_id]
                self.set_items = self.material_set_data["MaterialProfiles"] or []
                self.set_data = Data.profiles
                self.set_item_name = "profile"
            elif self.product_data["type"] == "IfcMaterialList":
                self.material_set_id = self.product_data["id"]
                self.material_set_data = Data.lists[self.material_set_id]
                self.set_items = self.material_set_data["Materials"] or []
                self.set_item_name = "list_item"
            else:
                self.material_set_id = 0
            return self.draw_material_ui()

        row = self.layout.row(align=True)
        row.prop(self.props, "material_type", text="")
        if self.props.material_type == "IfcMaterial" or self.props.material_type == "IfcMaterialList":
            row.prop(self.props, "material", text="")
        row.operator("bim.assign_material", icon="ADD", text="")
示例#10
0
    def create_profile(self):
        # A cube
        verts = [
            Vector((-1, -1, -1)),
            Vector((-1, -1, 1)),
            Vector((-1, 1, -1)),
            Vector((-1, 1, 1)),
            Vector((1, -1, -1)),
            Vector((1, -1, 1)),
            Vector((1, 1, -1)),
            Vector((1, 1, 1)),
        ]
        edges = []
        faces = [
            [0, 2, 3, 1],
            [2, 3, 7, 6],
            [4, 5, 7, 6],
            [0, 1, 5, 4],
            [1, 3, 7, 5],
            [0, 2, 6, 4],
        ]

        ifc_classes = ifcopenshell.util.type.get_applicable_entities(
            self.relating_type.is_a(), self.file.schema)
        # Standard cases are deprecated, so let's cull them
        ifc_class = [c for c in ifc_classes if "StandardCase" not in c][0]

        mesh = bpy.data.meshes.new(name="Dumb Profile")
        mesh.from_pydata(verts, edges, faces)
        obj = bpy.data.objects.new(
            tool.Model.generate_occurrence_name(self.relating_type, ifc_class),
            mesh)
        obj.location = self.location
        if self.collection_obj and self.collection_obj.BIMObjectProperties.ifc_definition_id:
            obj.location[2] = self.collection_obj.location[2]
        self.collection.objects.link(obj)

        bpy.ops.bim.assign_class(obj=obj.name,
                                 ifc_class=ifc_class,
                                 should_add_representation=False)

        if self.relating_type.is_a() in ["IfcBeamType", "IfcMemberType"]:
            obj.rotation_euler[0] = math.pi / 2
            obj.rotation_euler[2] = math.pi / 2

        element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
        blenderbim.core.type.assign_type(tool.Ifc,
                                         tool.Type,
                                         element=tool.Ifc.get_entity(obj),
                                         type=self.relating_type)
        profile_set_usage = ifcopenshell.util.element.get_material(element)
        pset = ifcopenshell.api.run("pset.add_pset",
                                    self.file,
                                    product=element,
                                    name="EPset_Parametric")
        ifcopenshell.api.run("pset.edit_pset",
                             self.file,
                             pset=pset,
                             properties={"Engine": "BlenderBIM.DumbProfile"})
        MaterialData.load(self.file)
        obj.select_set(True)
        return obj