Merge remote-tracking branch 'origin/v0.8.0' into datamodel-v1.0

This commit is contained in:
Thomas Krijnen
2026-04-18 20:15:28 +02:00
1655 changed files with 105534 additions and 46934 deletions
+23 -7
View File
@@ -31,6 +31,7 @@ bl_info = {
import importlib
import logging
import types
import bpy
from bpy_extras.io_utils import ExportHelper
@@ -80,7 +81,7 @@ ensure_addons_are_enabled("bonsai", "sverchok")
from sverchok.ui.nodeview_space_menu import add_node_menu
def nodes_index():
def nodes_index() -> list[tuple[str, list[tuple[str, str]]]]:
return [
(
"IFC",
@@ -110,15 +111,27 @@ def nodes_index():
("ifc.create_project", "SvIfcCreateProject"),
("ifc.quick_project_setup", "SvIfcQuickProjectSetup"),
],
)
),
(
"IFC Shape Builder",
[
("ifc.shape_builder.rectangle", "SvIfcSbRectangle"),
("ifc.shape_builder.extrude", "SvIfcSbExtrude"),
("ifc.shape_builder.representation", "SvIfcSbRepresentation"),
("ifc.shape_builder.test", "SvIfcSbTest"),
("ifc.shape_builder.shape_output", "SvSbShapeOutput"),
("ifc.shape_builder.mesh", "SvSbMesh"),
("ifc.shape_builder.polyline", "SvSbPolyline"),
],
),
]
def make_node_categories() -> list[dict[str, list[str]]]:
node_categories = [{}]
node_categories: list[dict[str, list[str]]] = []
for category, nodes in nodes_index():
nodes = [node_name for idname, node_name in nodes]
node_categories[0][category] = nodes
node_categories.append({category: nodes})
return node_categories
@@ -141,23 +154,24 @@ imported_modules = make_node_list()
reload_event = False
from os.path import splitext
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.aggregate
import ifcopenshell.api.root
import ifcopenshell.api.spatial
import ifcopenshell.util.element
from ifcsverchok.ifcstore import SvIfcStore
class IFC_Sv_UpdateCurrent(bpy.types.Operator):
"""Update current Sverchok node tree.
Will reset transient IFC file.
"""
Will reset transient IFC file"""
bl_idname = "ifc.sverchok_update_current"
bl_label = "Update Current Node Tree"
# bl_description = "Update current Sverchok node tree, resetting transient IFC file."
bl_options = {"REGISTER", "UNDO", "INTERNAL"}
node_group: bpy.props.StringProperty(default="")
@@ -284,11 +298,13 @@ class IFC_PT_write_file_panel(bpy.types.Panel):
def draw(self, context):
ng = context.space_data.node_tree
layout = self.layout
assert layout
row = layout.split(factor=0.2, align=True)
row = layout.row()
row2 = layout.row()
row.operator("ifc.sverchok_update_current", text="IFC Re-run all nodes")
row2.operator("ifc.write_file_panel")
layout.operator("bim.ifcsverchok_use_bonsai_file")
CLASSES = [IFC_Sv_UpdateCurrent, IFC_Sv_write_file, IFC_PT_write_file_panel]
+57 -2
View File
@@ -16,11 +16,14 @@
# You should have received a copy of the GNU General Public License
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
from typing import Any, Literal, TypeVar, Union
import bpy
import ifcopenshell
import sverchok.core.sockets
from sverchok.data_structure import zip_long_repeat
from typing import Any, Union, TypeVar
from sverchok.data_structure import flatten_data, zip_long_repeat
from ifcsverchok.ifcstore import SvIfcStore
T_socket = TypeVar("T_socket", bound=sverchok.core.sockets.SvSocketCommon)
@@ -66,6 +69,54 @@ def get_selected_nodes() -> list[bpy.types.Node]:
return [n for n in node_tree.nodes if n.select]
def get_socket_value(
sockets: Union[bpy.types.NodeInputs, bpy.types.NodeOutputs],
name: str,
*,
value_type: Literal["SINGLE_VALUE", "CONTAINER", "FLATTEN"] = "SINGLE_VALUE",
) -> Any:
"""
:param value_type:
- ``SINGLE_VALUE`` - e.g. ``[[x]]`` -> ``x``.
- ``CONTAINER`` - e.g. ``[ [ [x, y, z], [x,y, z] ] ]`` -> ``[ [x1, y1, z1], [x2, y2, z2] ]``.
- ``FLATTEN`` - e.g. `` [ [ [x1], [x2] ] ] `` -> `` [x1, x2] ``.
"""
socket = sockets[name]
assert isinstance(socket, sverchok.core.sockets.SvSocketCommon)
value = socket.sv_get()
if value_type == "FLATTEN":
return flatten_data(value)
value = value[0]
if value_type == "SINGLE_VALUE":
return value[0]
return value
def set_socket_value(
sockets: bpy.types.NodeOutputs,
name: str,
value: Any,
*,
value_type: Literal["SINGLE_VALUE", "FINAL_VALUE"] = "SINGLE_VALUE",
) -> None:
"""
:param value_type:
- ``SINGLE_VALUE`` - e.g. ``x`` -> ``[[x]]``.
- ``FINAL_VALUE`` - keep value as is.
"""
socket = sockets[name]
assert isinstance(socket, sverchok.core.sockets.SvSocketCommon)
if value_type == "SINGLE_VALUE":
socket.sv_set([[value]])
return
socket.sv_set(value)
def create_socket(
inputs_or_outputs: Union[bpy.types.NodeInputs, bpy.types.NodeOutputs],
name: str,
@@ -86,3 +137,7 @@ def create_socket(
if prop_name:
socket.prop_name = prop_name
return socket
def get_file() -> ifcopenshell.file:
return SvIfcStore.get_file()
+7 -2
View File
@@ -16,13 +16,14 @@
# You should have received a copy of the GNU General Public License
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
from typing import Any, Union
import bonsai.tool as tool
import bpy
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.context
import ifcopenshell.util.representation
from ifcopenshell import template
from typing import Union, Any
class SvIfcStore:
@@ -49,6 +50,8 @@ class SvIfcStore:
future = []
schema_identifiers = ["IFC4", "IFC2X3"]
use_bonsai_file = False
@staticmethod
def purge() -> None:
SvIfcStore.path = ""
@@ -94,6 +97,8 @@ class SvIfcStore:
@staticmethod
def get_file() -> ifcopenshell.file:
if SvIfcStore.use_bonsai_file:
return tool.Ifc.get()
if SvIfcStore.file is None:
SvIfcStore.create_boilerplate()
return SvIfcStore.file
+4 -3
View File
@@ -18,11 +18,12 @@
import bpy
import ifcopenshell
from bpy.props import StringProperty
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
class SvIfcAdd(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+7 -10
View File
@@ -16,23 +16,20 @@
# 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 json
import bpy
import ifcopenshell
import ifcopenshell.api.pset
import sverchok.core.sockets
from bpy.props import StringProperty
from sverchok.data_structure import flatten_data, updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from ifcsverchok.ifcstore import SvIfcStore
import json
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.pset
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data
class SvIfcAddPset(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcAddPset"
@@ -16,27 +16,24 @@
# 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 itertools import chain
import ifcopenshell
import ifcopenshell.api
import bpy
import ifcopenshell.api.aggregate
import ifcopenshell.api.root
import ifcopenshell.api.spatial
import ifcopenshell.util.element
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import (
updateNode,
ensure_min_nesting,
flatten_data,
repeat_last_for_length,
ensure_min_nesting,
updateNode,
)
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
class SvIfcAddSpatialElement(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+7 -6
View File
@@ -16,17 +16,18 @@
# You should have received a copy of the GNU General Public License
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
import logging
from typing import Any, Union
import bpy
import ifcopenshell
import ifcopenshell.api
import sverchok.core.sockets
from bpy.props import StringProperty
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from bpy.props import StringProperty, EnumProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
import logging
from typing import Union, Any
logger = logging.getLogger("sverchok.ifc")
+9 -18
View File
@@ -16,34 +16,25 @@
# You should have received a copy of the GNU General Public License
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
from copy import deepcopy
from decimal import Context
from email.policy import default
import bpy
import ifcopenshell
import ifcsverchok.helper
import ifcopenshell.api
import ifcopenshell.api.context
import ifcopenshell.api.geometry
import ifcopenshell.util.representation
from ifcsverchok.ifcstore import SvIfcStore
import bonsai.tool as tool
import bonsai.core.geometry as core
from bpy.props import (
StringProperty,
EnumProperty,
IntProperty,
BoolProperty,
EnumProperty,
PointerProperty,
StringProperty,
)
from mathutils import Matrix
from sverchok.data_structure import (
updateNode,
)
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data, fixed_iter, flat_iter
from bonsai.bim.module.root.prop import get_contexts
from sverchok.data_structure import zip_long_repeat, node_id
from sverchok.core.socket_data import sv_get_socket
from itertools import chain, cycle
from mathutils import Matrix
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
class SvIfcBMeshToIfcRepr(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
@@ -202,7 +193,7 @@ class SvIfcBMeshToIfcRepr(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.help
blender_object=obj,
geometry=obj.data,
context=context,
should_run_listeners=False,
should_run_listeners=False, # ty:ignore[unknown-argument]
)
if not representation:
raise Exception("Couldn't create representation. Possibly wrong context.")
+4 -4
View File
@@ -19,13 +19,13 @@
import itertools
import bpy
import ifcopenshell
from bpy.props import StringProperty
from sverchok.data_structure import flatten_data, updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data
class SvIfcByGuid(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+4 -3
View File
@@ -18,12 +18,13 @@
import bpy
from bpy.props import StringProperty
from sverchok.data_structure import flatten_data, updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data
class SvIfcById(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+22 -10
View File
@@ -17,23 +17,35 @@
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
import ifcopenshell.util.selector
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper as helper
from ifcsverchok.ifcstore import SvIfcStore
class SvIfcByQuery(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
class SvIfcByQuery(bpy.types.Node, SverchCustomTreeNode, helper.SvIfcCore):
bl_idname = "SvIfcByQuery"
bl_label = "IFC By Query"
query: StringProperty(name="Query", update=updateNode)
def sv_init(self, context):
self.inputs.new("SvStringsSocket", "query").prop_name = "query"
self.outputs.new("SvStringsSocket", "Entity")
def sv_init(self, context) -> None:
helper.create_socket(
self.inputs,
"query",
description="IFC Query string.",
data_type="list[list[str]]",
prop_name="query",
)
helper.create_socket(
self.outputs,
"Entity",
description="IFC Entities found by the query.",
data_type="set[ifcopenshell.entity_instance]",
prop_name="Entity",
)
def process(self):
if not self.inputs["query"].sv_get()[0][0]:
@@ -43,8 +55,8 @@ class SvIfcByQuery(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIf
super().process()
def process_ifc(self, query: str) -> None:
selector = ifcopenshell.util.selector.Selector()
self.outputs["Entity"].sv_set([selector.parse(self.file, query)])
elements = ifcopenshell.util.selector.filter_elements(self.file, query)
self.outputs["Entity"].sv_set(elements)
def register():
+5 -4
View File
@@ -18,11 +18,12 @@
import bpy
import ifcopenshell
import ifcsverchok.helper
from bpy.props import StringProperty, EnumProperty
from ifcsverchok.ifcstore import SvIfcStore
from sverchok.node_tree import SverchCustomTreeNode
from bpy.props import EnumProperty, StringProperty
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
def get_ifc_products(self, context):
+10 -12
View File
@@ -17,25 +17,23 @@
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
import bpy
from mathutils import Matrix
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.geometry
import ifcopenshell.api.root
import ifcopenshell.util.schema
from bpy.props import BoolProperty, StringProperty
from mathutils import Matrix
from sverchok.data_structure import (
ensure_min_nesting,
flatten_data,
repeat_last_for_length,
updateNode,
)
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty, BoolProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import (
updateNode,
flatten_data,
repeat_last_for_length,
ensure_min_nesting,
)
class SvIfcCreateEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcCreateEntity"
+4 -3
View File
@@ -19,12 +19,13 @@
import bpy
import ifcopenshell
import ifcopenshell.guid
import ifcsverchok.helper
import ifcsverchok.helper as helper
import sverchok.core.sockets
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
class SvIfcCreateFileRefresh(bpy.types.Operator):
+2 -2
View File
@@ -18,13 +18,13 @@
import bpy
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.context
import ifcopenshell.api.root
import ifcopenshell.api.unit
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from sverchok.node_tree import SverchCustomTreeNode
class SvIfcCreateProject(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+7 -8
View File
@@ -16,16 +16,17 @@
# 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 logging
import ifcopenshell
import bonsai.bim.import_ifc
import bpy
import ifcopenshell.geom
from bpy.props import BoolProperty, StringProperty
from sverchok.data_structure import flatten_data, updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
import bonsai.bim.import_ifc
from bpy.props import StringProperty, PointerProperty, BoolProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data
class SvIfcCreateShape(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
@@ -100,10 +101,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)
+2 -2
View File
@@ -17,11 +17,11 @@
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
import ifcopenshell.guid
import ifcsverchok.helper
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
class SvIfcGenerateGuid(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcGenerateGuid"
+4 -5
View File
@@ -17,13 +17,12 @@
# 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
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data
class SvIfcGetAttribute(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+4 -4
View File
@@ -17,13 +17,13 @@
# 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
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data
class SvIfcGetProperty(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+4 -3
View File
@@ -18,11 +18,12 @@
import bpy
import ifcopenshell
import ifcsverchok.helper
from bpy.props import EnumProperty
from ifcsverchok.ifcstore import SvIfcStore
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
def get_ifc_products(self, context):
@@ -16,17 +16,15 @@
# 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
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
from ifcopenshell import template
class SvIfcQuickProjectSetup(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+4 -3
View File
@@ -18,11 +18,12 @@
import bpy
import ifcopenshell
from bpy.props import StringProperty
from sverchok.data_structure import flatten_data, updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, ensure_min_nesting, flatten_data
class SvIfcReadEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+4 -3
View File
@@ -19,11 +19,12 @@
import bpy
import ifcopenshell
import ifcopenshell.guid
from bpy.props import StringProperty
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
class SvIfcReadFile(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+6 -4
View File
@@ -16,14 +16,16 @@
# You should have received a copy of the GNU General Public License
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
from typing import Union
import bpy
import ifcopenshell
from bpy.props import StringProperty
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
from typing import Union
class SvIfcRemove(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
@@ -16,15 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
import bonsai.tool as tool
import bpy
import ifcopenshell
import ifcopenshell.util.selector
import bonsai.tool as tool
from bpy.props import StringProperty
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
class SvIfcSelectBlenderObjectsRefresh(bpy.types.Operator):
@@ -0,0 +1,93 @@
# 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/>.
from typing import TYPE_CHECKING, Literal
import bpy
import ifcopenshell
import ifcsverchok.helper
import ifcsverchok.helper as helper
from ifcopenshell.util.shape_builder import ShapeBuilder
from sverchok.core.sockets import SvVerticesSocket
from sverchok.data_structure import updateNode
from sverchok.node_tree import SverchCustomTreeNode
class SvIfcSbExtrude(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcSbExtrude"
bl_label = "IFC Extrude"
extrude_axis: bpy.props.EnumProperty(
default="Z",
items=[
("X", "X", "Interpret curve as in XY plane and extrude along X+."),
("Y", "Y", "Interpret curve as in XZ plane and extrude along Y+."),
("Z", "Z", "Interpret curve as in XY plane and extrude along Z+."),
],
name="Extrude Axis",
update=updateNode,
)
if TYPE_CHECKING:
extrude_axis: Literal["X", "Y", "Z"]
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]]]",
socket_type=SvVerticesSocket,
)
helper.create_socket(
self.outputs,
"Extruded Profile",
description="Extruded Profile",
data_type="list[list[ifcopenshell.entity_instance]]",
)
def draw_buttons(self, context, layout):
layout.prop(self, "extrude_axis")
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)
axis_kargs = builder.extrude_kwargs(self.extrude_axis)
extrude = builder.extrude(curve, magnitude=magnitude, position=position, **axis_kargs)
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,51 @@
# 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 ifcsverchok.helper as helper
import sverchok.core.sockets
from ifcsverchok.nodes.ifc.shape_builder.representation import ShapeBuilder
from sverchok.node_tree import SverchCustomTreeNode
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)
@@ -0,0 +1,52 @@
# 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 ifcsverchok.helper as helper
import sverchok.core.sockets
from ifcsverchok.nodes.ifc.shape_builder.representation import ShapeBuilder
from sverchok.node_tree import SverchCustomTreeNode
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)
@@ -0,0 +1,56 @@
# 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 ifcsverchok.helper
import ifcsverchok.helper as helper
from ifcopenshell.util.shape_builder import ShapeBuilder
from sverchok.node_tree import SverchCustomTreeNode
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,63 @@
# 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
import ifcsverchok.helper
import ifcsverchok.helper as helper
from ifcopenshell.util.shape_builder import ShapeBuilder
from sverchok.node_tree import SverchCustomTreeNode
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,67 @@
# 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.geom
import ifcopenshell.ifcopenshell_wrapper as W
import ifcopenshell.util.shape
import ifcsverchok.helper as helper
import sverchok.core.sockets
from sverchok.node_tree import SverchCustomTreeNode
class SvSbShapeOutput(bpy.types.Node, SverchCustomTreeNode, helper.SvIfcCore):
"""
Triggers: Ifc create shape by entity
Tooltip: Convert IfcShapeRepresentation to geometry data.
"""
bl_idname = "SvSbShapeOutput"
bl_label = "IFC Shape Output"
def sv_init(self, context):
helper.create_socket(self.inputs, "Representation", data_type="list[list[ifcopenshell.entity_instance]]")
helper.create_socket(self.outputs, "Vers", socket_type=sverchok.core.sockets.SvVerticesSocket)
helper.create_socket(self.outputs, "Edgs")
helper.create_socket(self.outputs, "Pols")
def process(self):
entity: ifcopenshell.entity_instance = helper.get_socket_value(self.inputs, "Representation")
self.create(entity)
helper.set_socket_value(self.outputs, "Vers", [self.verts], value_type="FINAL_VALUE")
helper.set_socket_value(self.outputs, "Edgs", [self.edges], value_type="FINAL_VALUE")
helper.set_socket_value(self.outputs, "Pols", [self.polys], value_type="FINAL_VALUE")
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()
self.edges = ifcopenshell.util.shape.get_edges(shape).tolist()
self.polys = ifcopenshell.util.shape.get_faces(shape).tolist()
def register():
bpy.utils.register_class(SvSbShapeOutput)
def unregister():
bpy.utils.unregister_class(SvSbShapeOutput)
@@ -0,0 +1,54 @@
# 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 ifcsverchok.helper
import ifcsverchok.helper as helper
from sverchok.node_tree import SverchCustomTreeNode
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)
+6 -7
View File
@@ -17,16 +17,15 @@
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
import ifcsverchok.helper
import ifcopenshell.api
import ifcopenshell.api.context
import ifcopenshell.api.geometry
import ifcopenshell.util.representation
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty, EnumProperty, IntProperty, FloatVectorProperty
from bpy.props import EnumProperty, StringProperty
from sverchok.data_structure import ensure_min_nesting, updateNode
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, ensure_min_nesting
import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore
class SvIfcSverchokToIfcRepr(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
@@ -144,7 +143,7 @@ class SvIfcSverchokToIfcRepr(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.h
for item in obj:
representation = ifcopenshell.api.geometry.add_mesh_representation(
self.file,
should_run_listeners=False,
should_run_listeners=False, # ty:ignore[unknown-argument]
context=self.context,
vertices=[list(map(tuple, item[0]))],
edges=[list(map(tuple, item[1]))],
+5 -4
View File
@@ -17,19 +17,20 @@
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
from os.path import abspath, splitext
import bpy
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.aggregate
import ifcopenshell.api.root
import ifcopenshell.api.spatial
import ifcopenshell.util.element
from bpy.props import BoolProperty, StringProperty
from sverchok.data_structure import flatten_data, updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
import ifcsverchok.helper as helper
from ifcsverchok.ifcstore import SvIfcStore
from bpy.props import StringProperty, BoolProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data
class SvIfcWriteFile(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
+5
View File
@@ -0,0 +1,5 @@
[tool.ruff]
extend = "../../pyproject.toml"
lint.select = [
"F401", # unused imports
]