mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
You can now select coloured objects in a colourscheme.
This commit is contained in:
@@ -40,6 +40,7 @@ classes = (
|
||||
operator.SaveSearch,
|
||||
operator.SaveSelectorQuery,
|
||||
operator.Search,
|
||||
operator.SelectByProperty,
|
||||
operator.SelectFilterElements,
|
||||
operator.SelectGlobalId,
|
||||
operator.SelectIfcClass,
|
||||
|
||||
@@ -333,6 +333,36 @@ class ColourByProperty(Operator):
|
||||
data["area"].spaces[0].shading.color_type = "OBJECT"
|
||||
|
||||
|
||||
class SelectByProperty(Operator):
|
||||
bl_idname = "bim.select_by_property"
|
||||
bl_label = "Select by Property"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
props = context.scene.BIMSearchProperties
|
||||
return props.active_colourscheme_index < len(props.colourscheme)
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMSearchProperties
|
||||
query = props.colourscheme_query
|
||||
|
||||
if not query:
|
||||
self.report({"ERROR"}, "No Query Provided")
|
||||
return {"CANCELLED"}
|
||||
|
||||
active_value = props.colourscheme[props.active_colourscheme_index].name
|
||||
|
||||
for obj in context.visible_objects:
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if not element:
|
||||
continue
|
||||
value = str(ifcopenshell.util.selector.get_element_value(element, query))
|
||||
if value == active_value:
|
||||
obj.select_set(True)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SaveColourscheme(Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.save_colourscheme"
|
||||
bl_label = "Save Colourscheme"
|
||||
@@ -356,7 +386,9 @@ class SaveColourscheme(Operator, tool.Ifc.Operator):
|
||||
description["colourscheme_query"] = query
|
||||
group.Description = json.dumps(description)
|
||||
else:
|
||||
description = json.dumps({"type": "BBIM_Search", "colourscheme": coulour_scheme,"colourscheme_query": query})
|
||||
description = json.dumps(
|
||||
{"type": "BBIM_Search", "colourscheme": coulour_scheme, "colourscheme_query": query}
|
||||
)
|
||||
group = ifcopenshell.api.run("group.add_group", tool.Ifc.get(), Name=self.name, Description=description)
|
||||
|
||||
def invoke(self, context, event):
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import blenderbim.tool as tool
|
||||
from ifcopenshell import util
|
||||
from ifcopenshell.util.selector import Selector
|
||||
import blenderbim.tool as tool
|
||||
from blenderbim.bim.prop import ObjProperty, StrProperty
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.module.search.data import SearchData, ColourByPropertyData, SelectSimilarData
|
||||
|
||||
@@ -87,9 +87,12 @@ class BIM_PT_colour_by_property(Panel):
|
||||
row = self.layout.row(align=True)
|
||||
row.operator("bim.colour_by_property", icon="BRUSH_DATA")
|
||||
row.operator("bim.reset_object_colours")
|
||||
row.operator("bim.select_by_property", icon="RESTRICT_SELECT_OFF", text="")
|
||||
|
||||
if len(props.colourscheme):
|
||||
self.layout.template_list("BIM_UL_colourscheme", "", props, "colourscheme", props, "active_colourscheme_index")
|
||||
self.layout.template_list(
|
||||
"BIM_UL_colourscheme", "", props, "colourscheme", props, "active_colourscheme_index"
|
||||
)
|
||||
|
||||
|
||||
class BIM_PT_select_similar(Panel):
|
||||
|
||||
Reference in New Issue
Block a user