mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
allow to call select/color by attribute by providing arguments
instead of always checking scene.BIMSearchProperties. This allows to add different setups of selections to quick favorites
This commit is contained in:
@@ -143,20 +143,18 @@ class SelectAttribute(Operator):
|
|||||||
bl_label = "Select Attribute"
|
bl_label = "Select Attribute"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
@classmethod
|
attribute_name: bpy.props.StringProperty(default="")
|
||||||
def poll(cls, context):
|
attribute_value: bpy.props.StringProperty(default="")
|
||||||
props = context.scene.BIMSearchProperties
|
|
||||||
attribute_name = props.search_attribute_name.strip()
|
|
||||||
if attribute_name:
|
|
||||||
return True
|
|
||||||
cls.poll_message_set("Set Attribute Name for search.")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
attribute_name = self.attribute_name or context.scene.BIMSearchProperties.search_attribute_name
|
||||||
|
attribute_value = self.attribute_value
|
||||||
|
|
||||||
|
if not attribute_name:
|
||||||
|
self.report({"ERROR"}, "Set Attribute Name for search.")
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMSearchProperties
|
|
||||||
attribute_value = props.search_attribute_value
|
|
||||||
attribute_name = props.search_attribute_name
|
|
||||||
n_objects = 0
|
n_objects = 0
|
||||||
for obj in context.visible_objects:
|
for obj in context.visible_objects:
|
||||||
if not obj.BIMObjectProperties.ifc_definition_id:
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
@@ -181,25 +179,24 @@ class SelectPset(Operator):
|
|||||||
bl_label = "Select Pset"
|
bl_label = "Select Pset"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
@classmethod
|
pset_name: bpy.props.StringProperty(default="")
|
||||||
def poll(cls, context):
|
prop_name: bpy.props.StringProperty(default="")
|
||||||
props = context.scene.BIMSearchProperties
|
pset_value: bpy.props.StringProperty(default="")
|
||||||
pset_name = props.search_pset_name.strip()
|
|
||||||
prop_name = props.search_prop_name.strip()
|
|
||||||
if not pset_name:
|
|
||||||
cls.poll_message_set("Set PSet name for search.")
|
|
||||||
return False
|
|
||||||
if not prop_name:
|
|
||||||
cls.poll_message_set("Set Property name for search.")
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
search_pset_name = self.pset_name or context.scene.BIMSearchProperties.search_pset_name
|
||||||
|
search_prop_name = self.prop_name or context.scene.BIMSearchProperties.search_prop_name
|
||||||
|
pattern = self.pset_value
|
||||||
|
|
||||||
|
if not search_pset_name:
|
||||||
|
self.report({"ERROR"}, "Set PSet name for search.")
|
||||||
|
return {"CANCELLED"}
|
||||||
|
if not search_prop_name:
|
||||||
|
self.report({"ERROR"}, "Set Property name for search.")
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMSearchProperties
|
props = context.scene.BIMSearchProperties
|
||||||
search_pset_name = props.search_pset_name
|
|
||||||
search_prop_name = props.search_prop_name
|
|
||||||
pattern = props.search_pset_value
|
|
||||||
n_objects = 0
|
n_objects = 0
|
||||||
for obj in context.visible_objects:
|
for obj in context.visible_objects:
|
||||||
if not obj.BIMObjectProperties.ifc_definition_id:
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
@@ -231,9 +228,7 @@ class ColourByAttribute(Operator):
|
|||||||
bl_label = "Colour by Attribute"
|
bl_label = "Colour by Attribute"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
@classmethod
|
attribute_name: bpy.props.StringProperty(default="")
|
||||||
def poll(cls, context):
|
|
||||||
return SelectAttribute.poll(context)
|
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
IfcStore.begin_transaction(self)
|
IfcStore.begin_transaction(self)
|
||||||
@@ -244,10 +239,15 @@ class ColourByAttribute(Operator):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
|
attribute_name = self.attribute_name or context.scene.BIMSearchProperties.search_attribute_name
|
||||||
|
|
||||||
|
if not attribute_name:
|
||||||
|
self.report({"ERROR"}, "Set Attribute Name for search.")
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
colours = cycle(colour_list)
|
colours = cycle(colour_list)
|
||||||
values = {}
|
values = {}
|
||||||
attribute_name = context.scene.BIMSearchProperties.search_attribute_name
|
|
||||||
for obj in context.visible_objects:
|
for obj in context.visible_objects:
|
||||||
if not obj.BIMObjectProperties.ifc_definition_id:
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
continue
|
continue
|
||||||
@@ -286,9 +286,8 @@ class ColourByPset(Operator):
|
|||||||
bl_label = "Colour by Pset"
|
bl_label = "Colour by Pset"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
@classmethod
|
pset_name: bpy.props.StringProperty(default="")
|
||||||
def poll(cls, context):
|
prop_name: bpy.props.StringProperty(default="")
|
||||||
return SelectPset.poll(context)
|
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
IfcStore.begin_transaction(self)
|
IfcStore.begin_transaction(self)
|
||||||
@@ -299,11 +298,19 @@ class ColourByPset(Operator):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
|
search_pset_name = self.pset_name or context.scene.BIMSearchProperties.search_pset_name
|
||||||
|
search_prop_name = self.prop_name or context.scene.BIMSearchProperties.search_prop_name
|
||||||
|
|
||||||
|
if not search_pset_name:
|
||||||
|
self.report({"ERROR"}, "Set PSet name for search.")
|
||||||
|
return {"CANCELLED"}
|
||||||
|
if not search_prop_name:
|
||||||
|
self.report({"ERROR"}, "Set Property name for search.")
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
colours = cycle(colour_list)
|
colours = cycle(colour_list)
|
||||||
values = {}
|
values = {}
|
||||||
search_pset_name = context.scene.BIMSearchProperties.search_pset_name
|
|
||||||
search_prop_name = context.scene.BIMSearchProperties.search_prop_name
|
|
||||||
for obj in context.visible_objects:
|
for obj in context.visible_objects:
|
||||||
if not obj.BIMObjectProperties.ifc_definition_id:
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -53,15 +53,23 @@ class BIM_PT_search(Panel):
|
|||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(props, "search_attribute_name", text="", icon="PROPERTIES")
|
row.prop(props, "search_attribute_name", text="", icon="PROPERTIES")
|
||||||
row.prop(props, "search_attribute_value", text="")
|
row.prop(props, "search_attribute_value", text="")
|
||||||
row.operator("bim.select_attribute", text="", icon="VIEWZOOM")
|
op = row.operator("bim.select_attribute", text="", icon="VIEWZOOM")
|
||||||
row.operator("bim.colour_by_attribute", text="", icon="BRUSH_DATA")
|
op.attribute_name = props.search_attribute_name
|
||||||
|
op.attribute_value = props.search_attribute_value
|
||||||
|
op = row.operator("bim.colour_by_attribute", text="", icon="BRUSH_DATA")
|
||||||
|
op.attribute_name = props.search_attribute_name
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(props, "search_pset_name", text="", icon="COPY_ID")
|
row.prop(props, "search_pset_name", text="", icon="COPY_ID")
|
||||||
row.prop(props, "search_prop_name", text="")
|
row.prop(props, "search_prop_name", text="")
|
||||||
row.prop(props, "search_pset_value", text="")
|
row.prop(props, "search_pset_value", text="")
|
||||||
row.operator("bim.select_pset", text="", icon="VIEWZOOM")
|
op = row.operator("bim.select_pset", text="", icon="VIEWZOOM")
|
||||||
row.operator("bim.colour_by_pset", text="", icon="BRUSH_DATA")
|
op.pset_name = props.search_pset_name
|
||||||
|
op.prop_name = props.search_prop_name
|
||||||
|
op.pset_value = props.search_pset_value
|
||||||
|
op = row.operator("bim.colour_by_pset", text="", icon="BRUSH_DATA")
|
||||||
|
op.pset_name = props.search_pset_name
|
||||||
|
op.prop_name = props.search_prop_name
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.activate_ifc_class_filter", icon="FILTER")
|
row.operator("bim.activate_ifc_class_filter", icon="FILTER")
|
||||||
|
|||||||
Reference in New Issue
Block a user