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:
martinaCodes
2022-11-11 02:50:30 +01:00
committed by Dion Moult
parent 41ae350f33
commit 05633cd657
11 changed files with 508 additions and 169 deletions
+34 -6
View File
@@ -20,25 +20,53 @@ import bpy
import ifcopenshell
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
from sverchok.data_structure import updateNode, flatten_data
class SvIfcGetAttribute(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
class SvIfcGetAttribute(
bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore
):
bl_idname = "SvIfcGetAttribute"
bl_label = "IFC Get Attribute"
entity: StringProperty(name="entity", update=updateNode)
attribute_name: StringProperty(name="attribute_name", update=updateNode)
entity: StringProperty(name="Entity Ids", update=updateNode)
attribute_name: StringProperty(
name="Attribute name",
description='Name of attribute, eg. "Name".',
update=updateNode,
)
def sv_init(self, context):
self.inputs.new("SvStringsSocket", "entity").prop_name = "entity"
self.inputs.new("SvStringsSocket", "attribute_name").prop_name = "attribute_name"
self.inputs.new(
"SvStringsSocket", "attribute_name"
).prop_name = "attribute_name"
self.outputs.new("SvStringsSocket", "value")
def draw_buttons(self, context, layout):
layout.operator(
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
).tooltip = (
"Get the value of an attribute of an IfcEntity. Can take multiple entities."
)
def process(self):
self.value_out = []
entity_nested_inputs = self.inputs["entity"].sv_get()
entity_nested_input_ids = flatten_data(
self.inputs["entity"].sv_get(), target_level=1
)
if not entity_nested_input_ids[0]:
return
self.file = SvIfcStore.get_file()
try:
entity_nested_inputs = [
self.file.by_id(int(step_id)) for step_id in entity_nested_input_ids
]
print(entity_nested_inputs)
except Exception as e:
raise Exception("Instance ID not found", e)
attribute_name = self.inputs["attribute_name"].sv_get()[0][0]
for entities in entity_nested_inputs:
if hasattr(entities, "__iter__"):