mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
WIP port pset template module. It probably needs rewriting, but at least no regressions. See #1222.
This commit is contained in:
@@ -1321,129 +1321,6 @@ class CopyAttributeToSelection(bpy.types.Operator):
|
||||
return self.applicable_attributes_cache[ifc_class]
|
||||
|
||||
|
||||
class AddPropertySetTemplate(bpy.types.Operator):
|
||||
bl_idname = "bim.add_property_set_template"
|
||||
bl_label = "Add Property Set Template"
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.BIMProperties.active_property_set_template.global_id = ""
|
||||
context.scene.BIMProperties.active_property_set_template.name = "New_Pset"
|
||||
context.scene.BIMProperties.active_property_set_template.description = ""
|
||||
context.scene.BIMProperties.active_property_set_template.template_type = "PSET_TYPEDRIVENONLY"
|
||||
context.scene.BIMProperties.active_property_set_template.applicable_entity = "IfcTypeObject"
|
||||
while len(bpy.context.scene.BIMProperties.property_templates) > 0:
|
||||
bpy.context.scene.BIMProperties.property_templates.remove(0)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RemovePropertySetTemplate(bpy.types.Operator):
|
||||
bl_idname = "bim.remove_property_set_template"
|
||||
bl_label = "Remove Property Set Template"
|
||||
|
||||
def execute(self, context):
|
||||
template = ifc.IfcStore.pset_template_file.by_guid(context.scene.BIMProperties.property_set_templates)
|
||||
ifc.IfcStore.pset_template_file.remove(template)
|
||||
ifc.IfcStore.pset_template_file.write(ifc.IfcStore.pset_template_path)
|
||||
from . import prop
|
||||
|
||||
prop.refreshPropertySetTemplates(self, context)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class EditPropertySetTemplate(bpy.types.Operator):
|
||||
bl_idname = "bim.edit_property_set_template"
|
||||
bl_label = "Edit Property Set Template"
|
||||
|
||||
def execute(self, context):
|
||||
template = ifc.IfcStore.pset_template_file.by_guid(context.scene.BIMProperties.property_set_templates)
|
||||
context.scene.BIMProperties.active_property_set_template.global_id = template.GlobalId
|
||||
context.scene.BIMProperties.active_property_set_template.name = template.Name
|
||||
context.scene.BIMProperties.active_property_set_template.description = template.Description
|
||||
context.scene.BIMProperties.active_property_set_template.template_type = template.TemplateType
|
||||
context.scene.BIMProperties.active_property_set_template.applicable_entity = template.ApplicableEntity
|
||||
|
||||
while len(bpy.context.scene.BIMProperties.property_templates) > 0:
|
||||
bpy.context.scene.BIMProperties.property_templates.remove(0)
|
||||
|
||||
if template.HasPropertyTemplates:
|
||||
for property_template in template.HasPropertyTemplates:
|
||||
if not property_template.is_a("IfcSimplePropertyTemplate"):
|
||||
continue
|
||||
new = context.scene.BIMProperties.property_templates.add()
|
||||
new.global_id = property_template.GlobalId
|
||||
new.name = property_template.Name
|
||||
new.description = property_template.Description
|
||||
new.primary_measure_type = property_template.PrimaryMeasureType
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SavePropertySetTemplate(bpy.types.Operator):
|
||||
bl_idname = "bim.save_property_set_template"
|
||||
bl_label = "Save Property Set Template"
|
||||
|
||||
def execute(self, context):
|
||||
blender_property_set_template = context.scene.BIMProperties.active_property_set_template
|
||||
if blender_property_set_template.global_id:
|
||||
template = ifc.IfcStore.pset_template_file.by_guid(blender_property_set_template.global_id)
|
||||
else:
|
||||
template = ifc.IfcStore.pset_template_file.createIfcPropertySetTemplate()
|
||||
template.GlobalId = ifcopenshell.guid.new()
|
||||
template.Name = blender_property_set_template.name
|
||||
template.Description = blender_property_set_template.description
|
||||
template.TemplateType = blender_property_set_template.template_type
|
||||
template.ApplicableEntity = blender_property_set_template.applicable_entity
|
||||
|
||||
saved_global_ids = []
|
||||
|
||||
for blender_property_template in context.scene.BIMProperties.property_templates:
|
||||
if blender_property_template.global_id:
|
||||
property_template = ifc.IfcStore.pset_template_file.by_guid(blender_property_template.global_id)
|
||||
else:
|
||||
property_template = ifc.IfcStore.pset_template_file.createIfcSimplePropertyTemplate()
|
||||
property_template.GlobalId = ifcopenshell.guid.new()
|
||||
if template.HasPropertyTemplates:
|
||||
has_property_templates = list(template.HasPropertyTemplates)
|
||||
else:
|
||||
has_property_templates = []
|
||||
has_property_templates.append(property_template)
|
||||
template.HasPropertyTemplates = has_property_templates
|
||||
property_template.Name = blender_property_template.name
|
||||
property_template.Description = blender_property_template.description
|
||||
property_template.PrimaryMeasureType = blender_property_template.primary_measure_type
|
||||
property_template.TemplateType = "P_SINGLEVALUE"
|
||||
property_template.AccessState = "READWRITE"
|
||||
saved_global_ids.append(property_template.GlobalId)
|
||||
|
||||
for element in template.HasPropertyTemplates:
|
||||
if element.GlobalId not in saved_global_ids:
|
||||
ifc.IfcStore.pset_template_file.remove(element)
|
||||
|
||||
ifc.IfcStore.pset_template_file.write(ifc.IfcStore.pset_template_path)
|
||||
from . import prop
|
||||
|
||||
prop.refreshPropertySetTemplates(self, context)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddPropertyTemplate(bpy.types.Operator):
|
||||
bl_idname = "bim.add_property_template"
|
||||
bl_label = "Add Property Template"
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.BIMProperties.property_templates.add()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RemovePropertyTemplate(bpy.types.Operator):
|
||||
bl_idname = "bim.remove_property_template"
|
||||
bl_label = "Remove Property Template"
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
bpy.context.scene.BIMProperties.property_templates.remove(self.index)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddSectionPlane(bpy.types.Operator):
|
||||
bl_idname = "bim.add_section_plane"
|
||||
bl_label = "Add Temporary Section Cutaway"
|
||||
|
||||
Reference in New Issue
Block a user