Ejemplo n.º 1
0
 def add_resource_time(self):
     resource_time = ifcopenshell.api.run("resource.add_resource_time",
                                          self.file,
                                          resource=self.file.by_id(
                                              self.resource))
     Data.load(self.file)
     return resource_time
Ejemplo n.º 2
0
 def execute(self, context):
     self.file = IfcStore.get_file()
     ifcopenshell.api.run("resource.calculate_resource_work",
                          self.file,
                          resource=self.file.by_id(self.resource))
     Data.load(self.file)
     bpy.ops.bim.load_resources()
     return {"FINISHED"}
Ejemplo n.º 3
0
 def _execute(self, context):
     self.file = IfcStore.get_file()
     ifcopenshell.api.run(
         "resource.remove_resource_quantity",
         self.file,
         resource=self.file.by_id(self.resource),
     )
     Data.load(self.file)
     return {"FINISHED"}
Ejemplo n.º 4
0
 def execute(self, context):
     props = context.scene.BIMResourceProperties
     self.file = IfcStore.get_file()
     contracted_resources = json.loads(props.contracted_resources)
     contracted_resources.append(self.resource)
     props.contracted_resources = json.dumps(contracted_resources)
     Data.load(self.file)
     bpy.ops.bim.load_resources()
     return {"FINISHED"}
Ejemplo n.º 5
0
 def _execute(self, context):
     ifcopenshell.api.run(
         "resource.remove_resource",
         IfcStore.get_file(),
         resource=IfcStore.get_file().by_id(self.resource),
     )
     Data.load(IfcStore.get_file())
     bpy.ops.bim.load_resources()
     return {"FINISHED"}
Ejemplo n.º 6
0
 def _execute(self, context):
     ifcopenshell.api.run(
         "resource.add_resource",
         IfcStore.get_file(),
         parent_resource=IfcStore.get_file().by_id(self.resource)
         if self.resource else None,
         ifc_class=self.ifc_class,
     )
     Data.load(IfcStore.get_file())
     bpy.ops.bim.load_resources()
     return {"FINISHED"}
Ejemplo n.º 7
0
 def _execute(self, context):
     props = context.scene.BIMResourceProperties
     self.file = IfcStore.get_file()
     ifcopenshell.api.run(
         "cost.edit_cost_value_formula",
         self.file,
         **{
             "cost_value": self.file.by_id(self.cost_value),
             "formula": props.cost_value_formula
         },
     )
     Data.load(IfcStore.get_file())
     bpy.ops.bim.disable_editing_resource_cost_value()
     return {"FINISHED"}
Ejemplo n.º 8
0
 def execute(self, context):
     related_objects = ([bpy.data.objects.get(self.related_object)] if
                        self.related_object else context.selected_objects)
     for related_object in related_objects:
         self.file = IfcStore.get_file()
         ifcopenshell.api.run(
             "resource.unassign_resource",
             self.file,
             relating_resource=self.file.by_id(self.resource),
             related_object=self.file.by_id(
                 related_object.BIMObjectProperties.ifc_definition_id),
         )
     Data.load(self.file)
     return {"FINISHED"}
Ejemplo n.º 9
0
 def _execute(self, context):
     self.file = IfcStore.get_file()
     parent = self.file.by_id(self.parent)
     ifcopenshell.api.run(
         "cost.remove_cost_value",
         self.file,
         parent=parent,
         cost_value=self.file.by_id(self.cost_value),
     )
     if parent.is_a("IfcConstructionResource"):
         ResourceData.load(self.file)
     else:
         Data.load(self.file)
     return {"FINISHED"}
Ejemplo n.º 10
0
 def _execute(self, context):
     props = context.scene.BIMResourceProperties
     attributes = blenderbim.bim.helper.export_attributes(
         props.quantity_attributes)
     self.file = IfcStore.get_file()
     ifcopenshell.api.run(
         "resource.edit_resource_quantity",
         self.file,
         **{
             "physical_quantity": self.file.by_id(self.physical_quantity),
             "attributes": attributes
         },
     )
     Data.load(IfcStore.get_file())
     bpy.ops.bim.disable_editing_resource_quantity()
     return {"FINISHED"}
Ejemplo n.º 11
0
 def _execute(self, context):
     props = context.scene.BIMResourceProperties
     attributes = blenderbim.bim.helper.export_attributes(
         props.resource_attributes)
     self.file = IfcStore.get_file()
     ifcopenshell.api.run(
         "resource.edit_resource",
         self.file,
         **{
             "resource": self.file.by_id(props.active_resource_id),
             "attributes": attributes
         },
     )
     Data.load(IfcStore.get_file())
     bpy.ops.bim.load_resource_properties(resource=props.active_resource_id)
     bpy.ops.bim.disable_editing_resource()
     return {"FINISHED"}
Ejemplo n.º 12
0
 def _execute(self, context):
     props = context.scene.BIMResourceProperties
     attributes = blenderbim.bim.helper.export_attributes(
         props.cost_value_attributes,
         lambda attributes, prop: self.export_attributes(
             attributes, prop, context))
     self.file = IfcStore.get_file()
     ifcopenshell.api.run(
         "cost.edit_cost_value",
         self.file,
         **{
             "cost_value": self.file.by_id(self.cost_value),
             "attributes": attributes
         },
     )
     Data.load(IfcStore.get_file())
     bpy.ops.bim.disable_editing_resource_cost_value()
     return {"FINISHED"}
Ejemplo n.º 13
0
def updateResourceName(self, context):
    props = context.scene.BIMResourceProperties
    if not props.is_resource_update_enabled or self.name == "Unnamed":
        return
    self.file = IfcStore.get_file()
    ifcopenshell.api.run(
        "resource.edit_resource",
        self.file,
        **{
            "resource": self.file.by_id(self.ifc_definition_id),
            "attributes": {
                "Name": self.name
            }
        },
    )
    Data.load(IfcStore.get_file())
    if props.active_resource_id == self.ifc_definition_id:
        attribute = props.resource_attributes.get("Name")
        attribute.string_value = self.name
Ejemplo n.º 14
0
    def draw(self, context):
        self.props = context.scene.BIMResourceProperties
        self.tprops = context.scene.BIMResourceTreeProperties

        if not Data.is_loaded:
            Data.load(IfcStore.get_file())

        row = self.layout.row(align=True)
        row.label(text=f"{len(Data.resources)} Resources Found")
        if self.props.is_editing:
            row.operator("bim.disable_resource_editing_ui",
                         text="",
                         icon="CANCEL")
        else:
            row.operator("bim.load_resources", text="", icon="GREASEPENCIL")

        if not self.props.is_editing:
            return

        self.draw_resource_operators()
        self.layout.template_list(
            "BIM_UL_resources",
            "",
            self.tprops,
            "resources",
            self.props,
            "active_resource_index",
        )

        if self.props.active_resource_id and self.props.editing_resource_type == "ATTRIBUTES":
            self.draw_editable_resource_attributes_ui()
        elif self.props.active_resource_id and self.props.editing_resource_type == "QUANTITY":
            self.draw_editable_resource_quantity_ui()
        elif self.props.active_resource_id and self.props.editing_resource_type == "COSTS":
            self.draw_editable_resource_costs_ui()
        elif self.props.active_resource_id and self.props.editing_resource_type == "USAGE":
            self.draw_editable_resource_time_attributes_ui()
Ejemplo n.º 15
0
 def _execute(self, context):
     self.file = IfcStore.get_file()
     parent = self.file.by_id(self.parent)
     if self.cost_type == "FIXED":
         category = None
         attributes = {"AppliedValue": 0.0}
     elif self.cost_type == "SUM":
         category = "*"
         attributes = {"Category": category}
     elif self.cost_type == "CATEGORY":
         category = self.cost_category
         attributes = {"Category": category}
     value = ifcopenshell.api.run("cost.add_cost_value",
                                  self.file,
                                  parent=parent)
     ifcopenshell.api.run("cost.edit_cost_value",
                          self.file,
                          cost_value=value,
                          attributes=attributes)
     if parent.is_a("IfcConstructionResource"):
         ResourceData.load(self.file)
     else:
         Data.load(self.file)
     return {"FINISHED"}