Files
IfcOpenShell/src/ifcsverchok/nodes/ifc/by_id.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
2.3 KiB
Python
Raw Normal View History

2021-08-17 08:39:38 +10:00
# IfcSverchok - IFC Sverchok extension
# Copyright (C) 2022 Martina Jakubowska <martina@jakubowska.dk>
2021-08-17 08:39:38 +10:00
#
# 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
2025-12-19 18:53:04 +05:00
from bpy.props import StringProperty
from sverchok.data_structure import flatten_data, updateNode
from sverchok.node_tree import SverchCustomTreeNode
import ifcsverchok.helper
2025-03-21 18:35:19 +05:00
import ifcsverchok.helper as helper
2022-10-21 00:11:45 +02:00
from ifcsverchok.ifcstore import SvIfcStore
class SvIfcById(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcById"
bl_label = "IFC By Id"
2025-03-21 18:35:19 +05:00
bl_description = "Get IFC elements by step id from the transient IFC file."
id: StringProperty(
name="Id(s)",
update=updateNode,
)
def sv_init(self, context):
2025-03-21 18:35:19 +05:00
helper.create_socket(self.inputs, "id", description="Step ids.", data_type="list[list[str]]", prop_name="id")
helper.create_socket(
self.outputs,
"Entities",
description="Entities.",
data_type="list[ifcopenshell.entity_instance]",
prop_name="Entities",
)
2022-10-21 00:11:45 +02:00
def draw_buttons(self, context, layout):
2024-07-26 12:13:29 +10:00
layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
"Get IFC element by step id. Takes one or multiple step ids."
)
2020-11-01 19:24:01 +07:00
2022-10-21 00:11:45 +02:00
def process(self):
2022-10-23 20:25:36 +02:00
self.ids = flatten_data(self.inputs["id"].sv_get(), target_level=1)
if not self.ids[0]:
return
2022-10-21 00:11:45 +02:00
self.file = SvIfcStore.get_file()
2022-10-23 20:25:36 +02:00
self.entities = [self.file.by_id(int(step_id)) for step_id in self.ids]
2022-10-21 00:11:45 +02:00
self.outputs["Entities"].sv_set(self.entities)
def register():
bpy.utils.register_class(SvIfcById)
2020-11-01 19:24:01 +07:00
def unregister():
bpy.utils.unregister_class(SvIfcById)