2020-10-09 21:17:18 +11:00
|
|
|
import bpy
|
|
|
|
|
import ifcopenshell
|
|
|
|
|
import ifcopenshell.util.selector
|
|
|
|
|
import ifcsverchok.helper
|
|
|
|
|
from bpy.props import StringProperty
|
|
|
|
|
from sverchok.node_tree import SverchCustomTreeNode
|
|
|
|
|
from sverchok.data_structure import updateNode
|
2021-01-23 18:42:11 +11:00
|
|
|
from blenderbim.bim.ifc import IfcStore
|
2020-10-09 21:17:18 +11:00
|
|
|
|
|
|
|
|
|
2020-10-10 10:21:17 +11:00
|
|
|
class SvIfcSelectBlenderObjectsRefresh(bpy.types.Operator):
|
|
|
|
|
bl_idname = "node.sv_ifc_select_blender_objects_refresh"
|
|
|
|
|
bl_label = "IFC Select Blender Objects Refresh"
|
|
|
|
|
bl_options = {"UNDO"}
|
|
|
|
|
|
2021-07-03 14:34:15 +10:00
|
|
|
tree_name: StringProperty(default="")
|
|
|
|
|
node_name: StringProperty(default="")
|
2020-10-10 10:21:17 +11:00
|
|
|
|
|
|
|
|
def execute(self, context):
|
2021-07-03 14:34:15 +10:00
|
|
|
node = bpy.data.node_groups[self.tree_name].nodes[self.node_name]
|
2020-10-10 10:21:17 +11:00
|
|
|
node.process()
|
|
|
|
|
return {"FINISHED"}
|
|
|
|
|
|
|
|
|
|
|
2020-10-09 21:17:18 +11:00
|
|
|
class SvIfcSelectBlenderObjects(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
|
|
|
|
|
bl_idname = "SvIfcSelectBlenderObjects"
|
|
|
|
|
bl_label = "IFC Select Blender Objects"
|
|
|
|
|
file: StringProperty(name="file", update=updateNode)
|
|
|
|
|
query: StringProperty(name="query", update=updateNode)
|
|
|
|
|
|
|
|
|
|
def sv_init(self, context):
|
|
|
|
|
self.inputs.new("SvStringsSocket", "entities").prop_name = "entities"
|
|
|
|
|
|
2020-10-10 10:21:17 +11:00
|
|
|
def draw_buttons(self, context, layout):
|
2021-07-03 14:34:15 +10:00
|
|
|
op = layout.operator("node.sv_ifc_select_blender_objects_refresh", icon="FILE_REFRESH", text="Refresh")
|
|
|
|
|
op.tree_name = self.id_data.name
|
|
|
|
|
op.node_name = self.name
|
2020-10-10 10:21:17 +11:00
|
|
|
|
2020-10-09 21:17:18 +11:00
|
|
|
def process(self):
|
2021-01-23 18:42:11 +11:00
|
|
|
self.file = IfcStore.get_file()
|
2020-10-09 21:17:18 +11:00
|
|
|
self.sv_input_names = ["entities"]
|
|
|
|
|
self.guids = []
|
|
|
|
|
super().process()
|
|
|
|
|
for obj in bpy.context.visible_objects:
|
2021-01-23 18:42:11 +11:00
|
|
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
|
|
|
|
continue
|
|
|
|
|
if self.file.by_id(obj.BIMObjectProperties.ifc_definition_id).GlobalId in self.guids:
|
2020-10-09 21:17:18 +11:00
|
|
|
obj.select_set(True)
|
|
|
|
|
|
|
|
|
|
def process_ifc(self, entities):
|
|
|
|
|
self.guids.append(entities.GlobalId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def register():
|
2020-10-10 10:21:17 +11:00
|
|
|
bpy.utils.register_class(SvIfcSelectBlenderObjectsRefresh)
|
2020-10-09 21:17:18 +11:00
|
|
|
bpy.utils.register_class(SvIfcSelectBlenderObjects)
|
|
|
|
|
|
2020-11-01 19:24:01 +07:00
|
|
|
|
2020-10-09 21:17:18 +11:00
|
|
|
def unregister():
|
|
|
|
|
bpy.utils.unregister_class(SvIfcSelectBlenderObjects)
|
2020-10-10 10:21:17 +11:00
|
|
|
bpy.utils.unregister_class(SvIfcSelectBlenderObjectsRefresh)
|