mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
New select blender objects node - select objects in the Blender scene based off entities in an IFC file
This commit is contained in:
@@ -30,6 +30,7 @@ def nodes_index():
|
|||||||
("ifc.by_guid", "SvIfcByGuid"),
|
("ifc.by_guid", "SvIfcByGuid"),
|
||||||
("ifc.by_type", "SvIfcByType"),
|
("ifc.by_type", "SvIfcByType"),
|
||||||
("ifc.by_query", "SvIfcByQuery"),
|
("ifc.by_query", "SvIfcByQuery"),
|
||||||
|
("ifc.select_blender_objects", "SvIfcSelectBlenderObjects"),
|
||||||
])]
|
])]
|
||||||
|
|
||||||
def make_node_list():
|
def make_node_list():
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
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'
|
||||||
|
|
||||||
|
def process(self):
|
||||||
|
self.sv_input_names = ['entities']
|
||||||
|
self.guids = []
|
||||||
|
super().process()
|
||||||
|
for obj in bpy.context.visible_objects:
|
||||||
|
index = obj.BIMObjectProperties.attributes.find('GlobalId')
|
||||||
|
if index != -1 \
|
||||||
|
and obj.BIMObjectProperties.attributes[index].string_value in self.guids:
|
||||||
|
obj.select_set(True)
|
||||||
|
|
||||||
|
def process_ifc(self, entities):
|
||||||
|
self.guids.append(entities.GlobalId)
|
||||||
|
|
||||||
|
|
||||||
|
def register():
|
||||||
|
bpy.utils.register_class(SvIfcSelectBlenderObjects)
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
bpy.utils.unregister_class(SvIfcSelectBlenderObjects)
|
||||||
Reference in New Issue
Block a user