mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
added a new feature - remove psets
This commit is contained in:
@@ -34,6 +34,7 @@ classes = (
|
||||
operator.BIM_OT_clear_list,
|
||||
operator.BIM_OT_rename_parameters,
|
||||
operator.BIM_OT_add_edit_custom_property,
|
||||
operator.BIM_OT_bulk_remove_psets,
|
||||
prop.PsetProperties,
|
||||
prop.MaterialPsetProperties,
|
||||
prop.TaskPsetProperties,
|
||||
@@ -42,6 +43,7 @@ classes = (
|
||||
prop.WorkSchedulePsetProperties,
|
||||
prop.RenameProperties,
|
||||
prop.AddEditProperties,
|
||||
prop.DeletePsets,
|
||||
ui.BIM_PT_object_psets,
|
||||
ui.BIM_PT_object_qtos,
|
||||
ui.BIM_PT_material_psets,
|
||||
@@ -52,7 +54,8 @@ classes = (
|
||||
ui.BIM_PT_work_schedule_psets,
|
||||
ui.BIM_PT_bulk_property_editor,
|
||||
ui.BIM_PT_rename_parameters,
|
||||
ui.BIM_PT_add_edit_custom_properties
|
||||
ui.BIM_PT_add_edit_custom_properties,
|
||||
ui.BIM_PT_delete_psets
|
||||
)
|
||||
|
||||
|
||||
@@ -65,7 +68,7 @@ def register():
|
||||
bpy.types.Scene.WorkSchedulePsetProperties = bpy.props.PointerProperty(type=prop.WorkSchedulePsetProperties)
|
||||
bpy.types.Scene.RenameProperties = bpy.props.CollectionProperty(type=prop.RenameProperties)
|
||||
bpy.types.Scene.AddEditProperties = bpy.props.CollectionProperty(type=prop.AddEditProperties)
|
||||
|
||||
bpy.types.Scene.DeletePsets = bpy.props.CollectionProperty(type=prop.DeletePsets)
|
||||
|
||||
def unregister():
|
||||
del bpy.types.Object.PsetProperties
|
||||
@@ -76,3 +79,4 @@ def unregister():
|
||||
del bpy.types.Scene.WorkSchedulePsetProperties
|
||||
del bpy.types.Scene.RenameProperties
|
||||
del bpy.types.Scene.AddEditProperties
|
||||
del bpy.types.Scene.DeletePsets
|
||||
|
||||
@@ -484,3 +484,45 @@ class BIM_OT_add_edit_custom_property(bpy.types.Operator):
|
||||
|
||||
self.report({'INFO'}, 'Finished applying changes')
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class BIM_OT_bulk_remove_psets(bpy.types.Operator):
|
||||
bl_label = "Bulk remove psets from selected objects"
|
||||
bl_idname = "bim.bulk_remove_psets"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
bl_description = "Bulk remove psets from selected objects"
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
selected_objects = context.selected_objects
|
||||
props = context.scene.DeletePsets
|
||||
|
||||
for obj in selected_objects:
|
||||
ifc_definition_id = obj.BIMObjectProperties.ifc_definition_id
|
||||
if not ifc_definition_id:
|
||||
continue
|
||||
ifc_element = tool.Ifc.get().by_id(ifc_definition_id)
|
||||
psets = ifcopenshell.util.element.get_psets(ifc_element)
|
||||
|
||||
for prop in props:
|
||||
pset = prop.pset_name
|
||||
if pset in psets:
|
||||
try:
|
||||
ifcopenshell.api.run(
|
||||
"pset.remove_pset",
|
||||
self.file,
|
||||
**{
|
||||
"product": self.file.by_id(ifc_definition_id),
|
||||
"pset": self.file.by_id(psets[pset]["id"]),
|
||||
},
|
||||
)
|
||||
except KeyError:
|
||||
pass #Sometimes the pset id is not found, I'm not sure why this happens though. - vulevukusej
|
||||
Data.load(IfcStore.get_file(), ifc_definition_id)
|
||||
|
||||
self.report({'INFO'}, 'Finished applying changes')
|
||||
return {"FINISHED"}
|
||||
@@ -206,3 +206,7 @@ class AddEditProperties(PropertyGroup):
|
||||
return "int_value"
|
||||
elif self.data_type == "float":
|
||||
return "float_value"
|
||||
|
||||
|
||||
class DeletePsets(PropertyGroup):
|
||||
pset_name: StringProperty(name="Pset")
|
||||
|
||||
@@ -456,3 +456,36 @@ class BIM_PT_add_edit_custom_properties(Panel):
|
||||
clear = row.operator("bim.clear_list")
|
||||
clear.option = "AddEditProperties"
|
||||
op = row.operator("bim.add_edit_custom_property",icon="ADD", text="Apply Changes")
|
||||
|
||||
|
||||
class BIM_PT_delete_psets(Panel):
|
||||
bl_label = "Bulk remove psets from selected objects"
|
||||
bl_space_type = 'PROPERTIES'
|
||||
bl_region_type = 'WINDOW'
|
||||
bl_context = "object"
|
||||
bl_parent_id = "BIM_PT_bulk_property_editor"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
bl_order = 2
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
props = context.scene.DeletePsets
|
||||
|
||||
if props:
|
||||
for index, prop in enumerate(props):
|
||||
row = layout.row()
|
||||
row.prop(prop, "pset_name", text="Pset")
|
||||
op = row.operator("bim.remove_property_to_edit",icon="PANEL_CLOSE", text="")
|
||||
op.index = index
|
||||
op.option = "DeletePsets"
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.label()
|
||||
op = row.operator("bim.add_property_to_edit", icon="ADD",text="")
|
||||
op.option = "DeletePsets"
|
||||
|
||||
if props:
|
||||
row = layout.row()
|
||||
clear = row.operator("bim.clear_list")
|
||||
clear.option = "DeletePsets"
|
||||
op = row.operator("bim.bulk_remove_psets", text="Apply Changes")
|
||||
|
||||
Reference in New Issue
Block a user