diff --git a/src/ifcsverchok/__init__.py b/src/ifcsverchok/__init__.py index 8fc011b26a..2355ab6783 100644 --- a/src/ifcsverchok/__init__.py +++ b/src/ifcsverchok/__init__.py @@ -121,6 +121,7 @@ def nodes_index() -> list[tuple[str, list[tuple[str, str]]]]: ("ifc.shape_builder.test", "SvIfcSbTest"), ("ifc.shape_builder.shape_output", "SvSbShapeOutput"), ("ifc.shape_builder.mesh", "SvSbMesh"), + ("ifc.shape_builder.polyline", "SvSbPolyline"), ], ), ] diff --git a/src/ifcsverchok/nodes/ifc/shape_builder/polyline.py b/src/ifcsverchok/nodes/ifc/shape_builder/polyline.py new file mode 100644 index 0000000000..59e6c94804 --- /dev/null +++ b/src/ifcsverchok/nodes/ifc/shape_builder/polyline.py @@ -0,0 +1,53 @@ +# 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 SvSbPolyline(bpy.types.Node, SverchCustomTreeNode, helper.SvIfcCore): + bl_idname = "SvSbPolyline" + bl_label = "IFC Polyline" + bl_description = "Create closed polyline from vertices." + + def sv_init(self, context): + helper.create_socket(self.inputs, "Vers", socket_type=sverchok.core.sockets.SvVerticesSocket) + helper.create_socket(self.inputs, "Closed", data_type="list[list[bool]]") + 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") + closed = helper.get_socket_value(self.inputs, "Closed") + + builder = ShapeBuilder(ifc_file) + Polyline = builder.polyline(vertices, closed=closed) + helper.set_socket_value(self.outputs, "Representation Item", Polyline) + + +def register(): + bpy.utils.register_class(SvSbPolyline) + + +def unregister(): + bpy.utils.unregister_class(SvSbPolyline) diff --git a/src/ifcsverchok/nodes/ifc/shape_builder/shape_output.py b/src/ifcsverchok/nodes/ifc/shape_builder/shape_output.py index c3555c25e4..2968c5e4ed 100644 --- a/src/ifcsverchok/nodes/ifc/shape_builder/shape_output.py +++ b/src/ifcsverchok/nodes/ifc/shape_builder/shape_output.py @@ -52,6 +52,7 @@ class SvSbShapeOutput(bpy.types.Node, SverchCustomTreeNode, helper.SvIfcCore): def create(self, entity: ifcopenshell.entity_instance) -> None: assert bpy.context.scene settings = ifcopenshell.geom.settings() + settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS) shape = ifcopenshell.geom.create_shape(settings, entity) assert isinstance(shape, W.Triangulation) self.verts = ifcopenshell.util.shape.get_vertices(shape).tolist()