mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Build new attribute search operator with regex support and ignorecase
This commit is contained in:
@@ -75,6 +75,7 @@ if bpy is not None:
|
|||||||
operator.RemoveMaterialAttribute,
|
operator.RemoveMaterialAttribute,
|
||||||
operator.QuickProjectSetup,
|
operator.QuickProjectSetup,
|
||||||
operator.SelectGlobalId,
|
operator.SelectGlobalId,
|
||||||
|
operator.SelectAttribute,
|
||||||
operator.CreateAggregate,
|
operator.CreateAggregate,
|
||||||
operator.EditAggregate,
|
operator.EditAggregate,
|
||||||
operator.SaveAggregate,
|
operator.SaveAggregate,
|
||||||
@@ -114,6 +115,7 @@ if bpy is not None:
|
|||||||
prop.BIMCameraProperties,
|
prop.BIMCameraProperties,
|
||||||
ui.BIM_PT_documentation,
|
ui.BIM_PT_documentation,
|
||||||
ui.BIM_PT_bim,
|
ui.BIM_PT_bim,
|
||||||
|
ui.BIM_PT_search,
|
||||||
ui.BIM_PT_owner,
|
ui.BIM_PT_owner,
|
||||||
ui.BIM_PT_context,
|
ui.BIM_PT_context,
|
||||||
ui.BIM_PT_qa,
|
ui.BIM_PT_qa,
|
||||||
|
|||||||
@@ -99,11 +99,37 @@ class SelectGlobalId(bpy.types.Operator):
|
|||||||
for object in bpy.context.visible_objects:
|
for object in bpy.context.visible_objects:
|
||||||
index = object.BIMObjectProperties.attributes.find('GlobalId')
|
index = object.BIMObjectProperties.attributes.find('GlobalId')
|
||||||
if index != -1 \
|
if index != -1 \
|
||||||
and object.BIMObjectProperties.attributes[index].string_value == bpy.context.scene.BIMProperties.global_id:
|
and object.BIMObjectProperties.attributes[index].string_value == bpy.context.scene.BIMProperties.global_id:
|
||||||
object.select_set(True)
|
object.select_set(True)
|
||||||
break
|
break
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class SelectAttribute(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.select_attribute'
|
||||||
|
bl_label = 'Select Attribute'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
import re
|
||||||
|
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):
|
||||||
|
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'
|
||||||
|
|||||||
@@ -388,7 +388,11 @@ class BIMProperties(PropertyGroup):
|
|||||||
pset_file: EnumProperty(items=getPsetFiles, name="Pset File")
|
pset_file: EnumProperty(items=getPsetFiles, name="Pset File")
|
||||||
has_georeferencing: BoolProperty(name="Has Georeferencing", default=False)
|
has_georeferencing: BoolProperty(name="Has Georeferencing", default=False)
|
||||||
has_library: BoolProperty(name="Has Project Library", default=False)
|
has_library: BoolProperty(name="Has Project Library", default=False)
|
||||||
|
search_regex: BoolProperty(name="Search With Regex", default=False)
|
||||||
|
search_ignorecase: BoolProperty(name="Search Ignoring Case", default=True)
|
||||||
global_id: StringProperty(name="GlobalId")
|
global_id: StringProperty(name="GlobalId")
|
||||||
|
search_attribute_name: StringProperty(name="Search Attribute Name")
|
||||||
|
search_attribute_value: StringProperty(name="Search Attribute 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")
|
||||||
|
|||||||
@@ -410,13 +410,6 @@ class BIM_PT_bim(Panel):
|
|||||||
row.prop(bim_properties, "ifc_file")
|
row.prop(bim_properties, "ifc_file")
|
||||||
row.operator("bim.select_ifc_file", icon="FILE_FOLDER", text="")
|
row.operator("bim.select_ifc_file", icon="FILE_FOLDER", text="")
|
||||||
|
|
||||||
layout.label(text="Software Identity:")
|
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(bim_properties, 'global_id')
|
|
||||||
row = layout.row()
|
|
||||||
row.operator('bim.select_global_id')
|
|
||||||
|
|
||||||
layout.label(text="IFC Categorisation:")
|
layout.label(text="IFC Categorisation:")
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
@@ -471,6 +464,37 @@ class BIM_PT_bim(Panel):
|
|||||||
row.operator("bim.unassign_classification")
|
row.operator("bim.unassign_classification")
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_PT_search(Panel):
|
||||||
|
bl_label = "BIM Search"
|
||||||
|
bl_idname = "BIM_PT_search"
|
||||||
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
bl_space_type = 'PROPERTIES'
|
||||||
|
bl_region_type = 'WINDOW'
|
||||||
|
bl_context = "scene"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
|
||||||
|
scene = context.scene
|
||||||
|
props = scene.BIMProperties
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(props, 'search_regex')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(props, 'search_ignorecase')
|
||||||
|
|
||||||
|
layout.label(text="Global ID:")
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.prop(props, 'global_id', text='')
|
||||||
|
row.operator('bim.select_global_id', text='', icon='VIEWZOOM')
|
||||||
|
|
||||||
|
layout.label(text="Attribute:")
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.prop(props, 'search_attribute_name', text='')
|
||||||
|
row.prop(props, 'search_attribute_value', text='')
|
||||||
|
row.operator('bim.select_attribute', text='', icon='VIEWZOOM')
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_qa(Panel):
|
class BIM_PT_qa(Panel):
|
||||||
bl_label = "BIMTester Quality Auditing"
|
bl_label = "BIMTester Quality Auditing"
|
||||||
bl_idname = "BIM_PT_qa"
|
bl_idname = "BIM_PT_qa"
|
||||||
|
|||||||
Reference in New Issue
Block a user