Important rework of handling multiple/nested items in bmesh_to_ifc, create_entity and sverchok_to_ifc nodes. Formatting and other minor fixes.

This commit is contained in:
martinaCodes
2022-11-09 01:49:01 +01:00
committed by Dion Moult
parent 4ae7643874
commit 8a26f30506
30 changed files with 542 additions and 390 deletions
+12 -24
View File
@@ -1,6 +1,5 @@
# IfcSverchok - IFC Sverchok extension
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
# Copyright (C) 2022 Martina Jakubowska <martina@jakubowska.dk>
#
# This file is part of IfcSverchok.
#
@@ -28,29 +27,16 @@ from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data
# class SvIfcCreateShapeRefresh(bpy.types.Operator):
# bl_idname = "node.sv_ifc_create_shape_refresh"
# bl_label = "IFC Create Shape Refresh"
# bl_options = {"UNDO"}
# tree_name: StringProperty(default="")
# node_name: StringProperty(default="")
# def execute(self, context):
# node = bpy.data.node_groups[self.tree_name].nodes[self.node_name]
# node.process()
# return {"FINISHED"}
class SvIfcCreateShape(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
"""
Triggers: Ifc create shape by entity
Tooltip: Create Blender shape by Ifc Entity
"""
is_scene_dependent = True
is_interactive = False
node_dict = {}
def refresh_node(self, context):
if self.refresh_local:
self.process()
@@ -61,22 +47,23 @@ class SvIfcCreateShape(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.
bl_idname = "SvIfcCreateShape"
bl_label = "IFC Create Blender Shape"
entity: StringProperty(name="Entities", update=updateNode)
def sv_init(self, context):
self.inputs.new("SvStringsSocket", "Entities").prop_name = "entity"
self.outputs.new('SvStringsSocket', "Object(s)")
self.outputs.new("SvStringsSocket", "Object(s)")
def draw_buttons(self, context, layout):
row = layout.row(align=True)
row.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = "Create Blender shape from IfcEntity ID. Takes one or multiple IfcEntity IDs."
row.prop(self, 'refresh_local', icon='FILE_REFRESH')
row.operator(
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
).tooltip = "Create Blender shape from IfcEntity ID. Takes one or multiple IfcEntity IDs."
row.prop(self, "refresh_local", icon="FILE_REFRESH")
def process(self):
self.entities = flatten_data(self.inputs["Entities"].sv_get(), target_level = 1)
self.entities = flatten_data(self.inputs["Entities"].sv_get(), target_level=1)
if not self.entities[0]:
return
if self.refresh_local or hash(self) not in self.node_dict:
self.file = SvIfcStore.get_file()
try:
@@ -87,7 +74,7 @@ class SvIfcCreateShape(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.
self.node_dict[hash(self)] = blender_objects
else:
blender_objects = self.node_dict[hash(self)]
self.outputs["Object(s)"].sv_set(blender_objects)
def create(self):
@@ -110,6 +97,7 @@ class SvIfcCreateShape(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.
raise Exception("Entity could not be converted into a shape. Entity: {}".format(entity))
return blender_objects
def register():
# bpy.utils.register_class(SvIfcCreateShapeRefresh)
bpy.utils.register_class(SvIfcCreateShape)