ifcsverchok - experimenting with shape builder nodes

This commit is contained in:
Andrej730
2026-01-14 15:36:38 +05:00
parent 009652f97d
commit dbc0cca36e
12 changed files with 304 additions and 19 deletions
@@ -102,10 +102,8 @@ class SvIfcCreateShape(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.
def register():
# bpy.utils.register_class(SvIfcCreateShapeRefresh)
bpy.utils.register_class(SvIfcCreateShape)
def unregister():
bpy.utils.unregister_class(SvIfcCreateShape)
# bpy.utils.unregister_class(SvIfcCreateShapeRefresh)
@@ -17,7 +17,6 @@
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
import ifcopenshell.guid
from sverchok.node_tree import SverchCustomTreeNode
@@ -17,8 +17,6 @@
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
import ifcopenshell.util.element
from bpy.props import StringProperty
from sverchok.data_structure import flatten_data, updateNode
from sverchok.node_tree import SverchCustomTreeNode
@@ -17,7 +17,6 @@
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
import ifcopenshell.util.element
from bpy.props import StringProperty
from sverchok.data_structure import flatten_data, updateNode
@@ -16,11 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
from email.mime import application
import bpy
import ifcopenshell
import sverchok.core.sockets
from bpy.props import StringProperty
from ifcopenshell import template
+1 -1
View File
@@ -19,7 +19,7 @@
import bpy
import ifcopenshell
from bpy.props import StringProperty
from sverchok.data_structure import ensure_min_nesting, flatten_data, updateNode
from sverchok.data_structure import flatten_data, updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
@@ -0,0 +1,76 @@
# IfcSverchok - IFC Sverchok extension
# Copyright (C) 2022 Martina Jakubowska <martina@jakubowska.dk>
#
# 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 <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.context
import ifcopenshell.api.root
import ifcopenshell.api.unit
from ifcopenshell.util.shape_builder import ShapeBuilder
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from ifcsverchok.nodes.ifc.add_pset import flatten_data
class SvIfcSbExtrude(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcSbExtrude"
bl_label = "IFC Extrude"
def sv_init(self, context):
helper.create_socket(
self.inputs,
"Curve",
description="Curve to extrude",
data_type="list[list[ifcopenshell.entity_instance]]",
)
helper.create_socket(
self.inputs,
"Magnitude",
data_type="list[list[float]]",
)
helper.create_socket(
self.inputs,
"Position",
data_type="list[list[tuple[float, float, float]]]",
)
helper.create_socket(
self.outputs,
"Extruded Profile",
description="Extruded Profile",
data_type="list[list[ifcopenshell.entity_instance]]",
)
def process(self):
self.file = helper.get_file()
curve: ifcopenshell.entity_instance = helper.get_socket_value(self.inputs, "Curve")
magnitude: float = helper.get_socket_value(self.inputs, "Magnitude")
position: tuple[float, float, float] = helper.get_socket_value(self.inputs, "Position")
builder = ShapeBuilder(self.file)
extrude = builder.extrude(curve, magnitude=magnitude, position=position)
helper.set_socket_value(self.outputs, "Extruded Profile", extrude)
def register():
bpy.utils.register_class(SvIfcSbExtrude)
def unregister():
bpy.utils.unregister_class(SvIfcSbExtrude)
@@ -0,0 +1,57 @@
# IfcSverchok - IFC Sverchok extension
# Copyright (C) 2022 Martina Jakubowska <martina@jakubowska.dk>
#
# 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 <http://www.gnu.org/licenses/>.
import bpy
from ifcopenshell.util.shape_builder import ShapeBuilder
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
class SvIfcSbRectangle(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcSbRectangle"
bl_label = "IFC Rectangle"
def sv_init(self, context):
helper.create_socket(
self.inputs,
"Size (2D)",
data_type="list[list[tuple[float, float]]]",
)
helper.create_socket(
self.outputs,
"Rectangle",
description="Rectangle",
data_type="list[list[ifcopenshell.entity_instance]]",
)
def process(self):
file = helper.get_file()
builder = ShapeBuilder(file)
size: tuple[float, ...] = helper.get_socket_value(self.inputs, "Size", value_type="CONTAINER")
rectangle = builder.rectangle(size=size)
helper.set_socket_value(self.outputs, "Rectangle", rectangle)
def register():
bpy.utils.register_class(SvIfcSbRectangle)
def unregister():
bpy.utils.unregister_class(SvIfcSbRectangle)
@@ -0,0 +1,64 @@
# IfcSverchok - IFC Sverchok extension
# Copyright (C) 2022 Martina Jakubowska <martina@jakubowska.dk>
#
# 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 <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
import ifcopenshell.util.representation
from ifcopenshell.util.shape_builder import ShapeBuilder
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
class SvIfcSbRepresentation(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcSbRepresentation"
bl_label = "IFC Representation"
def sv_init(self, context):
helper.create_socket(
self.inputs,
"Representation Item",
description="Representation Item",
data_type="list[list[ifcopenshell.entity_instance]]",
)
helper.create_socket(
self.outputs,
"Shape Representation",
description="IfcShapeRepresentation",
data_type="list[list[ifcopenshell.entity_instance]]",
)
def process(self):
self.file = helper.get_file()
representation_items: list[ifcopenshell.entity_instance]
representation_items = helper.get_socket_value(self.inputs, "Representation Item", value_type="FLATTEN")
builder = ShapeBuilder(self.file)
context = ifcopenshell.util.representation.get_context(self.file, "Model", "Body", "MODEL_VIEW")
assert context is not None
representation = builder.get_representation(context, items=representation_items)
helper.set_socket_value(self.outputs, "Shape Representation", representation)
def register():
bpy.utils.register_class(SvIfcSbRepresentation)
def unregister():
bpy.utils.unregister_class(SvIfcSbRepresentation)
@@ -0,0 +1,55 @@
# IfcSverchok - IFC Sverchok extension
# Copyright (C) 2022 Martina Jakubowska <martina@jakubowska.dk>
#
# 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 <http://www.gnu.org/licenses/>.
import bpy
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
class SvIfcSbTest(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcSbTest"
bl_label = "IFC Test"
def sv_init(self, context):
helper.create_socket(
self.inputs,
"Input",
)
helper.create_socket(
self.outputs,
"Output",
description="Extruded Profile",
)
def process(self):
print("test!")
self.sv_input_names = ["Input"]
super().process()
def process_ifc(self, input_value: float) -> None:
self.outputs["Output"].sv_set([[input_value]])
def register():
bpy.utils.register_class(SvIfcSbTest)
def unregister():
bpy.utils.unregister_class(SvIfcSbTest)