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
+10 -6
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.
#
@@ -17,8 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty
@@ -29,24 +28,29 @@ from sverchok.data_structure import updateNode, flatten_data
class SvIfcById(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcById"
bl_label = "IFC By Id"
id: StringProperty(name="Id(s)", update=updateNode, )
id: StringProperty(
name="Id(s)",
update=updateNode,
)
def sv_init(self, context):
self.inputs.new("SvStringsSocket", "id").prop_name = "id"
self.outputs.new("SvStringsSocket", "Entities")
def draw_buttons(self, context, layout):
layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = "Get IFC element by step id. Takes one or multiple step ids."
layout.operator(
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
).tooltip = "Get IFC element by step id. Takes one or multiple step ids."
def process(self):
self.ids = flatten_data(self.inputs["id"].sv_get(), target_level=1)
print(self.ids)
if not self.ids[0]:
return
self.file = SvIfcStore.get_file()
self.entities = [self.file.by_id(int(step_id)) for step_id in self.ids]
self.outputs["Entities"].sv_set(self.entities)
def register():
bpy.utils.register_class(SvIfcById)