mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-02 21:12:07 +00:00
Updated following nodes to work with the current workflow: add_pset, by_guid, get_attribute, get_property, read_entity. Added tooltips and other minor fixes
This commit is contained in:
@@ -16,31 +16,48 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import itertools
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
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.data_structure import updateNode, flatten_data
|
||||
|
||||
|
||||
class SvIfcByGuid(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
|
||||
bl_idname = "SvIfcByGuid"
|
||||
bl_label = "IFC By Guid"
|
||||
file: StringProperty(name="file", update=updateNode)
|
||||
guid: StringProperty(name="guid", update=updateNode)
|
||||
n_id: StringProperty(default="")
|
||||
guid: StringProperty(name="Guid(s)", update=updateNode)
|
||||
id_iter = itertools.count()
|
||||
|
||||
def sv_init(self, context):
|
||||
self.inputs.new("SvStringsSocket", "file").prop_name = "file"
|
||||
self.inputs.new("SvStringsSocket", "guid").prop_name = "guid"
|
||||
self.outputs.new("SvStringsSocket", "entity")
|
||||
self.outputs.new("SvStringsSocket", "Entities")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = "Get IFC element by guid. Takes one or multiple guids."
|
||||
|
||||
def process(self):
|
||||
self.sv_input_names = ["file", "guid"]
|
||||
super().process()
|
||||
print("\n\n", "#" * 30, "Running SvIfcByGuid node", "#" * 30)
|
||||
print("self: ", self)
|
||||
print("id(self): ", id(self))
|
||||
print("hash(self): ", hash(self))
|
||||
print("node_id: ", self.node_id)
|
||||
self.id = next(self.id_iter)
|
||||
print("self.id (itertool counter): ", self.id)
|
||||
|
||||
def process_ifc(self, file, guid):
|
||||
self.outputs["entity"].sv_set([[file.by_guid(guid)]])
|
||||
self.guids = flatten_data(self.inputs["guid"].sv_get(), target_level=1)
|
||||
if not self.guids[0]:
|
||||
return
|
||||
self.file = SvIfcStore.get_file()
|
||||
self.entities = [self.file.by_guid(guid) for guid in self.guids]
|
||||
self.outputs["Entities"].sv_set(self.entities)
|
||||
|
||||
|
||||
def register():
|
||||
|
||||
Reference in New Issue
Block a user