diff --git a/src/ifcsverchok/__init__.py b/src/ifcsverchok/__init__.py index 4594d8a367..8fc011b26a 100644 --- a/src/ifcsverchok/__init__.py +++ b/src/ifcsverchok/__init__.py @@ -120,6 +120,7 @@ def nodes_index() -> list[tuple[str, list[tuple[str, str]]]]: ("ifc.shape_builder.representation", "SvIfcSbRepresentation"), ("ifc.shape_builder.test", "SvIfcSbTest"), ("ifc.shape_builder.shape_output", "SvSbShapeOutput"), + ("ifc.shape_builder.mesh", "SvSbMesh"), ], ), ] diff --git a/src/ifcsverchok/nodes/ifc/shape_builder/mesh.py b/src/ifcsverchok/nodes/ifc/shape_builder/mesh.py new file mode 100644 index 0000000000..ec2609613e --- /dev/null +++ b/src/ifcsverchok/nodes/ifc/shape_builder/mesh.py @@ -0,0 +1,52 @@ +# IfcSverchok - IFC Sverchok extension +# Copyright (C) 2022 Martina Jakubowska +# +# This file is part of IfcSverchok. +# +# IfcSverchok is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# IfcSverchok is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with IfcSverchok. If not, see . + +import bpy +import sverchok.core.sockets +from ifcsverchok.nodes.ifc.shape_builder.representation import ShapeBuilder +from sverchok.node_tree import SverchCustomTreeNode + +import ifcsverchok.helper as helper + + +class SvSbMesh(bpy.types.Node, SverchCustomTreeNode, helper.SvIfcCore): + bl_idname = "SvSbMesh" + bl_label = "IFC Mesh" + + def sv_init(self, context): + helper.create_socket(self.inputs, "Vers", socket_type=sverchok.core.sockets.SvVerticesSocket) + helper.create_socket(self.inputs, "Pols") + helper.create_socket(self.outputs, "Representation Item", data_type="list[list[ifcopenshell.entity_instance]]") + + def process(self): + ifc_file = helper.get_file() + + vertices: list[[list[float]]] = helper.get_socket_value(self.inputs, "Vers", value_type="CONTAINER") + polygons: list[[list[int]]] = helper.get_socket_value(self.inputs, "Pols", value_type="CONTAINER") + + builder = ShapeBuilder(ifc_file) + mesh = builder.mesh(vertices, polygons) + helper.set_socket_value(self.outputs, "Representation Item", mesh) + + +def register(): + bpy.utils.register_class(SvSbMesh) + + +def unregister(): + bpy.utils.unregister_class(SvSbMesh)