Beispiel #1
0
 def _execute(self, context):
     props = context.scene.BIMPsetTemplateProperties
     ifcopenshell.api.run(
         "pset_template.remove_prop_template",
         IfcStore.pset_template_file,
         **{"prop_template": IfcStore.pset_template_file.by_id(self.prop_template)}
     )
     Data.load(IfcStore.pset_template_file)
     return {"FINISHED"}
Beispiel #2
0
 def _execute(self, context):
     props = context.scene.BIMPsetTemplateProperties
     pset_template_id = props.active_pset_template_id or int(props.pset_templates)
     ifcopenshell.api.run(
         "pset_template.add_prop_template",
         IfcStore.pset_template_file,
         **{"pset_template": IfcStore.pset_template_file.by_id(pset_template_id)}
     )
     Data.load(IfcStore.pset_template_file)
     return {"FINISHED"}
Beispiel #3
0
 def _execute(self, context):
     props = context.scene.BIMPsetTemplateProperties
     if props.active_pset_template_id == int(props.pset_templates):
         bpy.ops.bim.disable_editing_pset_template()
     ifcopenshell.api.run(
         "pset_template.remove_pset_template",
         IfcStore.pset_template_file,
         **{"pset_template": IfcStore.pset_template_file.by_id(int(props.pset_templates))}
     )
     Data.load(IfcStore.pset_template_file)
     updatePsetTemplates(self, context)
     return {"FINISHED"}
Beispiel #4
0
def getPsetTemplates(self, context):
    global psettemplates_enum
    if len(psettemplates_enum) < 1:
        if not IfcStore.pset_template_file:
            IfcStore.pset_template_path = os.path.join(
                context.scene.BIMProperties.data_dir,
                "pset",
                context.scene.BIMPsetTemplateProperties.pset_template_files + ".ifc",
            )
            IfcStore.pset_template_file = ifcopenshell.open(IfcStore.pset_template_path)
        templates = IfcStore.pset_template_file.by_type("IfcPropertySetTemplate")
        psettemplates_enum.extend([(str(t.id()), t.Name, "") for t in templates])
        Data.load(IfcStore.pset_template_file)
    return psettemplates_enum
Beispiel #5
0
 def _execute(self, context):
     props = context.scene.BIMPsetTemplateProperties
     ifcopenshell.api.run(
         "pset_template.edit_prop_template",
         IfcStore.pset_template_file,
         **{
             "prop_template": IfcStore.pset_template_file.by_id(props.active_prop_template_id),
             "attributes": {
                 "Name": props.active_prop_template.name,
                 "Description": props.active_prop_template.description,
                 "PrimaryMeasureType": props.active_prop_template.primary_measure_type,
             },
         }
     )
     Data.load(IfcStore.pset_template_file)
     bpy.ops.bim.disable_editing_prop_template()
     return {"FINISHED"}
Beispiel #6
0
 def _execute(self, context):
     props = context.scene.BIMPsetTemplateProperties
     ifcopenshell.api.run(
         "pset_template.edit_pset_template",
         IfcStore.pset_template_file,
         **{
             "pset_template": IfcStore.pset_template_file.by_id(props.active_pset_template_id),
             "attributes": {
                 "Name": props.active_pset_template.name,
                 "Description": props.active_pset_template.description,
                 "TemplateType": props.active_pset_template.template_type,
                 "ApplicableEntity": props.active_pset_template.applicable_entity,
             },
         }
     )
     Data.load(IfcStore.pset_template_file)
     updatePsetTemplates(self, context)
     bpy.ops.bim.disable_editing_pset_template()
     return {"FINISHED"}
Beispiel #7
0
    def draw(self, context):
        layout = self.layout
        props = context.scene.BIMPsetTemplateProperties

        row = layout.row(align=True)
        row.prop(props, "pset_template_files", text="")
        row.operator("bim.save_pset_template_file", text="", icon="EXPORT")

        row = layout.row(align=True)

        if bool(getPsetTemplates(props, context)):
            row.prop(props, "pset_templates", text="", icon="COPY_ID")
        else:
            row.label(text="No Pset Templates", icon="COPY_ID")

        if props.active_pset_template_id:
            row.operator("bim.edit_pset_template", text="", icon="CHECKMARK")
            row.operator("bim.disable_editing_pset_template",
                         text="",
                         icon="CANCEL")
        else:
            row.operator("bim.add_pset_template", text="", icon="ADD")
            row.operator("bim.enable_editing_pset_template",
                         text="",
                         icon="GREASEPENCIL")
            row.operator("bim.remove_pset_template", text="", icon="X")

        if not Data.is_loaded and props.pset_template_files:
            Data.load(IfcStore.pset_template_file)

        if not Data.pset_templates:
            return

        if props.active_pset_template_id:
            pset_template = Data.pset_templates[int(
                props.active_pset_template_id)]
            row = layout.row()
            row.prop(props.active_pset_template, "name")
            row = layout.row()
            row.prop(props.active_pset_template, "description")
            row = layout.row()
            row.prop(props.active_pset_template, "template_type")
            row = layout.row()
            row.prop(props.active_pset_template, "applicable_entity")
        else:
            pset_template = Data.pset_templates[int(props.pset_templates)]
            for name, value in pset_template.items():
                if name == "id" or name == "type" or name == "HasPropertyTemplates":
                    continue
                row = layout.row(align=True)
                row.label(text=name)
                row.label(text=str(value))

        row = layout.row(align=True)
        row.label(text="Property Templates", icon="COPY_ID")
        row.operator("bim.add_prop_template", icon="ADD", text="")

        for prop_template_id in pset_template["HasPropertyTemplates"]:
            prop_template = Data.prop_templates[prop_template_id]
            row = layout.row(align=True)

            if props.active_prop_template_id and props.active_prop_template_id == prop_template_id:
                row.prop(props.active_prop_template, "name", text="")
                row.prop(props.active_prop_template, "description", text="")
                row.prop(props.active_prop_template,
                         "primary_measure_type",
                         text="")
            else:
                row.label(text=prop_template["Name"])
                row.label(text=prop_template["Description"])
                row.label(text=prop_template["PrimaryMeasureType"])

            if props.active_prop_template_id and props.active_prop_template_id == prop_template_id:
                op = row.operator("bim.edit_prop_template",
                                  icon="CHECKMARK",
                                  text="")
                row.operator("bim.disable_editing_prop_template",
                             icon="CANCEL",
                             text="")
            elif props.active_prop_template_id and props.active_prop_template_id != prop_template_id:
                row.operator("bim.remove_prop_template", icon="X",
                             text="").prop_template = prop_template_id
            else:
                op = row.operator("bim.enable_editing_prop_template",
                                  icon="GREASEPENCIL",
                                  text="")
                op.prop_template = prop_template_id
                row.operator("bim.remove_prop_template", icon="X",
                             text="").prop_template = prop_template_id
Beispiel #8
0
 def _execute(self, context):
     props = context.scene.BIMPsetTemplateProperties
     ifcopenshell.api.run("pset_template.add_pset_template", IfcStore.pset_template_file)
     Data.load(IfcStore.pset_template_file)
     updatePsetTemplates(self, context)
     return {"FINISHED"}