mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 08:13:14 +00:00
Add ability to search with regex for pset values
This commit is contained in:
@@ -76,6 +76,7 @@ if bpy is not None:
|
|||||||
operator.QuickProjectSetup,
|
operator.QuickProjectSetup,
|
||||||
operator.SelectGlobalId,
|
operator.SelectGlobalId,
|
||||||
operator.SelectAttribute,
|
operator.SelectAttribute,
|
||||||
|
operator.SelectPset,
|
||||||
operator.CreateAggregate,
|
operator.CreateAggregate,
|
||||||
operator.EditAggregate,
|
operator.EditAggregate,
|
||||||
operator.SaveAggregate,
|
operator.SaveAggregate,
|
||||||
|
|||||||
@@ -110,12 +110,12 @@ class SelectAttribute(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
import re
|
import re
|
||||||
|
search_value = bpy.context.scene.BIMProperties.search_attribute_value
|
||||||
for object in bpy.context.visible_objects:
|
for object in bpy.context.visible_objects:
|
||||||
index = object.BIMObjectProperties.attributes.find(bpy.context.scene.BIMProperties.search_attribute_name)
|
index = object.BIMObjectProperties.attributes.find(bpy.context.scene.BIMProperties.search_attribute_name)
|
||||||
if index == -1:
|
if index == -1:
|
||||||
continue
|
continue
|
||||||
value = object.BIMObjectProperties.attributes[index].string_value
|
value = object.BIMObjectProperties.attributes[index].string_value
|
||||||
search_value = bpy.context.scene.BIMProperties.search_attribute_value
|
|
||||||
if bpy.context.scene.BIMProperties.search_regex \
|
if bpy.context.scene.BIMProperties.search_regex \
|
||||||
and bpy.context.scene.BIMProperties.search_ignorecase \
|
and bpy.context.scene.BIMProperties.search_ignorecase \
|
||||||
and re.search(search_value, value, flags=re.IGNORECASE):
|
and re.search(search_value, value, flags=re.IGNORECASE):
|
||||||
@@ -130,6 +130,39 @@ class SelectAttribute(bpy.types.Operator):
|
|||||||
object.select_set(True)
|
object.select_set(True)
|
||||||
return {'FINISHED'}
|
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):
|
class AssignClass(bpy.types.Operator):
|
||||||
bl_idname = 'bim.assign_class'
|
bl_idname = 'bim.assign_class'
|
||||||
bl_label = 'Assign IFC Class'
|
bl_label = 'Assign IFC Class'
|
||||||
|
|||||||
@@ -393,6 +393,8 @@ class BIMProperties(PropertyGroup):
|
|||||||
global_id: StringProperty(name="GlobalId")
|
global_id: StringProperty(name="GlobalId")
|
||||||
search_attribute_name: StringProperty(name="Search Attribute Name")
|
search_attribute_name: StringProperty(name="Search Attribute Name")
|
||||||
search_attribute_value: StringProperty(name="Search Attribute Value")
|
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_dir: StringProperty(default='', name="Features Directory", update=refreshFeaturesFiles)
|
||||||
features_file: EnumProperty(items=getFeaturesFiles, name="Features File", update=refreshScenarios)
|
features_file: EnumProperty(items=getFeaturesFiles, name="Features File", update=refreshScenarios)
|
||||||
scenario: EnumProperty(items=getScenarios, name="Scenario")
|
scenario: EnumProperty(items=getScenarios, name="Scenario")
|
||||||
|
|||||||
@@ -495,6 +495,12 @@ class BIM_PT_search(Panel):
|
|||||||
row.prop(props, 'search_attribute_value', text='')
|
row.prop(props, 'search_attribute_value', text='')
|
||||||
row.operator('bim.select_attribute', text='', icon='VIEWZOOM')
|
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):
|
class BIM_PT_qa(Panel):
|
||||||
bl_label = "BIMTester Quality Auditing"
|
bl_label = "BIMTester Quality Auditing"
|
||||||
|
|||||||
Reference in New Issue
Block a user