Add ability to search with regex for pset values

This commit is contained in:
Dion Moult
2020-02-20 17:31:38 +11:00
parent eac8925134
commit 7a5ec24d8d
4 changed files with 43 additions and 1 deletions
@@ -76,6 +76,7 @@ if bpy is not None:
operator.QuickProjectSetup,
operator.SelectGlobalId,
operator.SelectAttribute,
operator.SelectPset,
operator.CreateAggregate,
operator.EditAggregate,
operator.SaveAggregate,
+34 -1
View File
@@ -110,12 +110,12 @@ class SelectAttribute(bpy.types.Operator):
def execute(self, context):
import re
search_value = bpy.context.scene.BIMProperties.search_attribute_value
for object in bpy.context.visible_objects:
index = object.BIMObjectProperties.attributes.find(bpy.context.scene.BIMProperties.search_attribute_name)
if index == -1:
continue
value = object.BIMObjectProperties.attributes[index].string_value
search_value = bpy.context.scene.BIMProperties.search_attribute_value
if bpy.context.scene.BIMProperties.search_regex \
and bpy.context.scene.BIMProperties.search_ignorecase \
and re.search(search_value, value, flags=re.IGNORECASE):
@@ -130,6 +130,39 @@ class SelectAttribute(bpy.types.Operator):
object.select_set(True)
return {'FINISHED'}
class SelectPset(bpy.types.Operator):
bl_idname = 'bim.select_pset'
bl_label = 'Select Pset'
def execute(self, context):
import re
search_pset_name = bpy.context.scene.BIMProperties.search_pset_path.split('.')[0]
search_prop_name = bpy.context.scene.BIMProperties.search_pset_path.split('.')[1]
search_value = bpy.context.scene.BIMProperties.search_pset_value
for object in bpy.context.visible_objects:
pset_index = object.BIMObjectProperties.override_psets.find(search_pset_name)
if pset_index == -1:
continue
prop_index = object.BIMObjectProperties.override_psets[pset_index].properties.find(search_prop_name)
if prop_index == -1:
continue
value = object.BIMObjectProperties.override_psets[pset_index].properties[prop_index].string_value
if bpy.context.scene.BIMProperties.search_regex \
and bpy.context.scene.BIMProperties.search_ignorecase \
and re.search(search_value, value, flags=re.IGNORECASE):
object.select_set(True)
elif bpy.context.scene.BIMProperties.search_regex \
and re.search(search_value, value):
object.select_set(True)
elif bpy.context.scene.BIMProperties.search_ignorecase \
and value.lower() == search_value.lower():
object.select_set(True)
elif value == search_value:
object.select_set(True)
return {'FINISHED'}
class AssignClass(bpy.types.Operator):
bl_idname = 'bim.assign_class'
bl_label = 'Assign IFC Class'
+2
View File
@@ -393,6 +393,8 @@ class BIMProperties(PropertyGroup):
global_id: StringProperty(name="GlobalId")
search_attribute_name: StringProperty(name="Search Attribute Name")
search_attribute_value: StringProperty(name="Search Attribute Value")
search_pset_path: StringProperty(name="Search Pset Path")
search_pset_value: StringProperty(name="Search Pset Value")
features_dir: StringProperty(default='', name="Features Directory", update=refreshFeaturesFiles)
features_file: EnumProperty(items=getFeaturesFiles, name="Features File", update=refreshScenarios)
scenario: EnumProperty(items=getScenarios, name="Scenario")
+6
View File
@@ -495,6 +495,12 @@ class BIM_PT_search(Panel):
row.prop(props, 'search_attribute_value', text='')
row.operator('bim.select_attribute', text='', icon='VIEWZOOM')
layout.label(text="Pset:")
row = layout.row(align=True)
row.prop(props, 'search_pset_path', text='')
row.prop(props, 'search_pset_value', text='')
row.operator('bim.select_pset', text='', icon='VIEWZOOM')
class BIM_PT_qa(Panel):
bl_label = "BIMTester Quality Auditing"