mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 22:16:41 +00:00
Run black on utils
This commit is contained in:
@@ -55,9 +55,9 @@ class SvIfcAddPset(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIf
|
||||
self.outputs.new("SvStringsSocket", "Entity")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = "Add a property set and corresponding properties to IfcElements."
|
||||
layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Add a property set and corresponding properties to IfcElements."
|
||||
)
|
||||
|
||||
def process(self):
|
||||
if not any(socket.is_linked for socket in self.outputs):
|
||||
@@ -83,9 +83,7 @@ class SvIfcAddPset(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIf
|
||||
def create(self, name, properties, elements):
|
||||
results = []
|
||||
for element in elements:
|
||||
result = ifcopenshell.api.run(
|
||||
"pset.add_pset", self.file, product=element, name=name
|
||||
)
|
||||
result = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name=name)
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
self.file,
|
||||
|
||||
@@ -24,7 +24,8 @@ from bpy.props import StringProperty, EnumProperty
|
||||
from sverchok.node_tree import SverchCustomTreeNode
|
||||
from sverchok.data_structure import updateNode
|
||||
import logging
|
||||
logger = logging.getLogger('sverchok.ifc')
|
||||
|
||||
logger = logging.getLogger("sverchok.ifc")
|
||||
|
||||
|
||||
def update_usecase(self, context):
|
||||
|
||||
@@ -42,9 +42,7 @@ from sverchok.core.socket_data import sv_get_socket
|
||||
from itertools import chain, cycle
|
||||
|
||||
|
||||
class SvIfcBMeshToIfcRepr(
|
||||
bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore
|
||||
):
|
||||
class SvIfcBMeshToIfcRepr(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
|
||||
"""
|
||||
Triggers: BMesh to Ifc Repr
|
||||
Tooltip: Blender mesh to Ifc Shape Representation
|
||||
@@ -61,9 +59,7 @@ class SvIfcBMeshToIfcRepr(
|
||||
self.process()
|
||||
self.refresh_local = False
|
||||
|
||||
refresh_local: BoolProperty(
|
||||
name="Update Node", description="Update Node", update=refresh_node
|
||||
)
|
||||
refresh_local: BoolProperty(name="Update Node", description="Update Node", update=refresh_node)
|
||||
|
||||
context_types = [
|
||||
("Model", "Model", "Context type: Model", 0),
|
||||
@@ -113,20 +109,16 @@ class SvIfcBMeshToIfcRepr(
|
||||
|
||||
def sv_init(self, context):
|
||||
self.inputs.new("SvStringsSocket", "context_type").prop_name = "context_type"
|
||||
self.inputs.new(
|
||||
"SvStringsSocket", "context_identifier"
|
||||
).prop_name = "context_identifier"
|
||||
self.inputs.new("SvStringsSocket", "context_identifier").prop_name = "context_identifier"
|
||||
self.inputs.new("SvStringsSocket", "target_view").prop_name = "target_view"
|
||||
self.inputs.new(
|
||||
"SvObjectSocket", "blender_objects"
|
||||
).prop_name = "blender_objects" # no prop for now
|
||||
self.inputs.new("SvObjectSocket", "blender_objects").prop_name = "blender_objects" # no prop for now
|
||||
self.outputs.new("SvVerticesSocket", "Representations")
|
||||
self.outputs.new("SvMatrixSocket", "Locations")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = "Blender mesh to Ifc Shape Representation. \nTakes one or multiple geometries.\nDeconstructs joined geometries and creates a separate representation for each."
|
||||
layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Blender mesh to Ifc Shape Representation. \nTakes one or multiple geometries.\nDeconstructs joined geometries and creates a separate representation for each."
|
||||
)
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(self, "is_interactive", icon="SCENE_DATA", icon_only=True)
|
||||
@@ -136,9 +128,7 @@ class SvIfcBMeshToIfcRepr(
|
||||
self.sv_input_names = [i.name for i in self.inputs]
|
||||
|
||||
if hash(self) not in self.node_dict:
|
||||
self.node_dict[
|
||||
hash(self)
|
||||
] = {} # happens if node is already on canvas when blender loads
|
||||
self.node_dict[hash(self)] = {} # happens if node is already on canvas when blender loads
|
||||
if not self.node_dict[hash(self)]:
|
||||
self.node_dict[hash(self)].update(dict.fromkeys(self.sv_input_names, 0))
|
||||
|
||||
@@ -211,21 +201,17 @@ class SvIfcBMeshToIfcRepr(
|
||||
context=context,
|
||||
)
|
||||
if not representation:
|
||||
raise Exception(
|
||||
"Couldn't create representation. Possibly wrong context."
|
||||
)
|
||||
raise Exception("Couldn't create representation. Possibly wrong context.")
|
||||
|
||||
representations_ids_obj.append([representation.id()])
|
||||
locations_obj.append([obj.matrix_world])
|
||||
representations_ids.append(representations_ids_obj)
|
||||
locations.append(locations_obj)
|
||||
|
||||
SvIfcStore.id_map.setdefault(self.node_id, {}).setdefault(
|
||||
"Representations", []
|
||||
).append(representations_ids_obj)
|
||||
SvIfcStore.id_map.setdefault(self.node_id, {}).setdefault(
|
||||
"Locations", []
|
||||
).append(locations_obj)
|
||||
SvIfcStore.id_map.setdefault(self.node_id, {}).setdefault("Representations", []).append(
|
||||
representations_ids_obj
|
||||
)
|
||||
SvIfcStore.id_map.setdefault(self.node_id, {}).setdefault("Locations", []).append(locations_obj)
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
return representations_ids, locations
|
||||
|
||||
@@ -248,13 +234,9 @@ class SvIfcBMeshToIfcRepr(
|
||||
self.file, self.context_type, self.context_identifier, self.target_view
|
||||
)
|
||||
if not context:
|
||||
parent = ifcopenshell.util.representation.get_context(
|
||||
self.file, self.context_type
|
||||
)
|
||||
parent = ifcopenshell.util.representation.get_context(self.file, self.context_type)
|
||||
if not parent:
|
||||
parent = ifcopenshell.api.run(
|
||||
"context.add_context", self.file, context_type=self.context_type
|
||||
)
|
||||
parent = ifcopenshell.api.run("context.add_context", self.file, context_type=self.context_type)
|
||||
context = ifcopenshell.api.run(
|
||||
"context.add_context",
|
||||
self.file,
|
||||
@@ -263,9 +245,7 @@ class SvIfcBMeshToIfcRepr(
|
||||
target_view=self.target_view,
|
||||
parent=parent,
|
||||
)
|
||||
SvIfcStore.id_map.setdefault(self.node_id, {}).setdefault(
|
||||
"Contexts", []
|
||||
).append(context.id())
|
||||
SvIfcStore.id_map.setdefault(self.node_id, {}).setdefault("Contexts", []).append(context.id())
|
||||
return context
|
||||
|
||||
def sv_free(self):
|
||||
@@ -286,14 +266,10 @@ class SvIfcBMeshToIfcRepr(
|
||||
if not self.file.get_inverse(context):
|
||||
if self.file.by_id(context_id).ParentContext:
|
||||
parent = self.file.by_id(context_id).ParentContext
|
||||
ifcopenshell.api.run(
|
||||
"context.remove_context", self.file, context=context
|
||||
)
|
||||
ifcopenshell.api.run("context.remove_context", self.file, context=context)
|
||||
if parent:
|
||||
if not self.file.get_inverse(parent):
|
||||
ifcopenshell.api.run(
|
||||
"context.remove_context", self.file, context=parent
|
||||
)
|
||||
ifcopenshell.api.run("context.remove_context", self.file, context=parent)
|
||||
SvIfcStore.id_map[self.node_id]["Contexts"].remove(context_id)
|
||||
del SvIfcStore.id_map[self.node_id]
|
||||
del self.node_dict[hash(self)]
|
||||
|
||||
@@ -39,9 +39,9 @@ class SvIfcByGuid(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfc
|
||||
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."
|
||||
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.guids = flatten_data(self.inputs["guid"].sv_get(), target_level=1)
|
||||
|
||||
@@ -38,9 +38,9 @@ class SvIfcById(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCo
|
||||
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 step id. Takes one or multiple step ids."
|
||||
layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Get IFC element by step id. Takes one or multiple step ids."
|
||||
)
|
||||
|
||||
def process(self):
|
||||
self.ids = flatten_data(self.inputs["id"].sv_get(), target_level=1)
|
||||
|
||||
@@ -108,17 +108,15 @@ class SvIfcByType(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfc
|
||||
def sv_init(self, context):
|
||||
self.inputs.new("SvStringsSocket", "ifc_product").prop_name = "ifc_product"
|
||||
self.inputs.new("SvStringsSocket", "ifc_class").prop_name = "ifc_class"
|
||||
self.inputs.new(
|
||||
"SvStringsSocket", "custom_ifc_class"
|
||||
).prop_name = "custom_ifc_class"
|
||||
self.inputs.new("SvStringsSocket", "custom_ifc_class").prop_name = "custom_ifc_class"
|
||||
self.outputs.new("SvStringsSocket", "Entities")
|
||||
self.outputs.new("SvStringsSocket", "Entity Ids")
|
||||
self.width = 200
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = "Get IFC element(s) in file by type. \nPick an IfcProduct and an IfcClass or give a custom IfcClass."
|
||||
layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Get IFC element(s) in file by type. \nPick an IfcProduct and an IfcClass or give a custom IfcClass."
|
||||
)
|
||||
|
||||
def process(self):
|
||||
self.file = SvIfcStore.get_file()
|
||||
|
||||
@@ -32,9 +32,7 @@ from sverchok.data_structure import (
|
||||
)
|
||||
|
||||
|
||||
class SvIfcCreateEntity(
|
||||
bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore
|
||||
):
|
||||
class SvIfcCreateEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
|
||||
bl_idname = "SvIfcCreateEntity"
|
||||
bl_label = "IFC Create Entity"
|
||||
node_dict = {}
|
||||
@@ -46,9 +44,7 @@ class SvIfcCreateEntity(
|
||||
self.process()
|
||||
self.refresh_local = False
|
||||
|
||||
refresh_local: BoolProperty(
|
||||
name="Update Node", description="Update Node", update=refresh_node
|
||||
)
|
||||
refresh_local: BoolProperty(name="Update Node", description="Update Node", update=refresh_node)
|
||||
|
||||
Names: StringProperty(
|
||||
name="Names",
|
||||
@@ -76,18 +72,16 @@ class SvIfcCreateEntity(
|
||||
self.inputs.new("SvStringsSocket", "Names").prop_name = "Names"
|
||||
self.inputs.new("SvStringsSocket", "Descriptions").prop_name = "Descriptions"
|
||||
self.inputs.new("SvStringsSocket", "IfcClass").prop_name = "IfcClass"
|
||||
self.inputs.new(
|
||||
"SvStringsSocket", "Representations"
|
||||
).prop_name = "Representations"
|
||||
self.inputs.new("SvStringsSocket", "Representations").prop_name = "Representations"
|
||||
self.inputs.new("SvMatrixSocket", "Locations").is_mandatory = False
|
||||
# self.inputs.new("SvStringsSocket", "Properties").prop_name = "Properties"
|
||||
self.outputs.new("SvStringsSocket", "Entities")
|
||||
self.node_dict[hash(self)] = {}
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = "Create IFC Entity. Takes one or multiple inputs. \nIf 'Representation(s)' is given, that determines number of output entities. Otherwise, 'Names' is used."
|
||||
layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Create IFC Entity. Takes one or multiple inputs. \nIf 'Representation(s)' is given, that determines number of output entities. Otherwise, 'Names' is used."
|
||||
)
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(self, "is_interactive", icon="SCENE_DATA", icon_only=True)
|
||||
@@ -95,26 +89,16 @@ class SvIfcCreateEntity(
|
||||
|
||||
def process(self):
|
||||
self.names = flatten_data(self.inputs["Names"].sv_get(), target_level=1)
|
||||
self.descriptions = flatten_data(
|
||||
self.inputs["Descriptions"].sv_get(), target_level=1
|
||||
)
|
||||
self.ifc_class = flatten_data(self.inputs["IfcClass"].sv_get(), target_level=1)[
|
||||
0
|
||||
]
|
||||
self.representations = ensure_min_nesting(
|
||||
self.inputs["Representations"].sv_get(), 3
|
||||
)
|
||||
self.descriptions = flatten_data(self.inputs["Descriptions"].sv_get(), target_level=1)
|
||||
self.ifc_class = flatten_data(self.inputs["IfcClass"].sv_get(), target_level=1)[0]
|
||||
self.representations = ensure_min_nesting(self.inputs["Representations"].sv_get(), 3)
|
||||
self.representations = flatten_data(self.representations, target_level=3)
|
||||
self.locations = ensure_min_nesting(
|
||||
self.inputs["Locations"].sv_get(default=[]), 3
|
||||
)
|
||||
self.locations = ensure_min_nesting(self.inputs["Locations"].sv_get(default=[]), 3)
|
||||
self.locations = flatten_data(self.locations, target_level=3)
|
||||
self.sv_input_names = [i.name for i in self.inputs]
|
||||
|
||||
if hash(self) not in self.node_dict:
|
||||
self.node_dict[
|
||||
hash(self)
|
||||
] = {} # happens if node is already on canvas when blender loads
|
||||
self.node_dict[hash(self)] = {} # happens if node is already on canvas when blender loads
|
||||
if not self.node_dict[hash(self)]:
|
||||
self.node_dict[hash(self)].update(dict.fromkeys(self.sv_input_names, 0))
|
||||
if not self.inputs["IfcClass"].sv_get()[0][0]:
|
||||
@@ -122,9 +106,7 @@ class SvIfcCreateEntity(
|
||||
|
||||
edit = False
|
||||
for i in range(len(self.inputs)):
|
||||
input = self.inputs[self.sv_input_names[i]].sv_get(
|
||||
deepcopy=True, default=[]
|
||||
)
|
||||
input = self.inputs[self.sv_input_names[i]].sv_get(deepcopy=True, default=[])
|
||||
if (
|
||||
isinstance(self.node_dict[hash(self)][self.inputs[i].name], list)
|
||||
and input != self.node_dict[hash(self)][self.inputs[i].name]
|
||||
@@ -142,27 +124,18 @@ class SvIfcCreateEntity(
|
||||
for group in self.representations:
|
||||
try:
|
||||
group_representations = [
|
||||
[self.file.by_id(step_id) for step_id in representation]
|
||||
for representation in group
|
||||
[self.file.by_id(step_id) for step_id in representation] for representation in group
|
||||
]
|
||||
representations.append(group_representations)
|
||||
except Exception as e:
|
||||
raise
|
||||
names.append(
|
||||
self.repeat_input_unique(self.names, len(group_representations))
|
||||
)
|
||||
descriptions.append(
|
||||
self.repeat_input_unique(
|
||||
self.descriptions, len(group_representations)
|
||||
)
|
||||
)
|
||||
names.append(self.repeat_input_unique(self.names, len(group_representations)))
|
||||
descriptions.append(self.repeat_input_unique(self.descriptions, len(group_representations)))
|
||||
self.representations = representations
|
||||
self.names = names
|
||||
self.descriptions = descriptions
|
||||
elif not self.representations[0][0][0]:
|
||||
self.descriptions = self.repeat_input_unique(
|
||||
self.descriptions, len(self.names)
|
||||
)
|
||||
self.descriptions = self.repeat_input_unique(self.descriptions, len(self.names))
|
||||
self.names = ensure_min_nesting(self.names, 2)
|
||||
self.descriptions = ensure_min_nesting(self.descriptions, 2)
|
||||
if self.node_id not in SvIfcStore.id_map:
|
||||
@@ -193,7 +166,7 @@ class SvIfcCreateEntity(
|
||||
self.file,
|
||||
ifc_class=self.ifc_class,
|
||||
name=self.names[i][j],
|
||||
#description=self.descriptions[i][j],
|
||||
# description=self.descriptions[i][j],
|
||||
)
|
||||
try:
|
||||
for repr in self.representations[i][j]:
|
||||
@@ -266,9 +239,7 @@ class SvIfcCreateEntity(
|
||||
pass
|
||||
if entity.is_a() != self.ifc_class:
|
||||
SvIfcStore.id_map[self.node_id][i].remove(step_id)
|
||||
entity = ifcopenshell.util.schema.reassign_class(
|
||||
self.file, entity, self.ifc_class
|
||||
)
|
||||
entity = ifcopenshell.util.schema.reassign_class(self.file, entity, self.ifc_class)
|
||||
group_entities_ids.append(entity.id())
|
||||
entities_ids.append(group_entities_ids)
|
||||
|
||||
@@ -280,12 +251,10 @@ class SvIfcCreateEntity(
|
||||
if input[0]:
|
||||
if flag:
|
||||
return [
|
||||
[a] if not (s := sum(j == a for j in input[:i])) else [f"{a}-{s+1}"]
|
||||
for i, a in enumerate(input)
|
||||
[a] if not (s := sum(j == a for j in input[:i])) else [f"{a}-{s+1}"] for i, a in enumerate(input)
|
||||
]
|
||||
input = [
|
||||
a if not (s := sum(j == a for j in input[:i])) else f"{a}-{s+1}"
|
||||
for i, a in enumerate(input)
|
||||
a if not (s := sum(j == a for j in input[:i])) else f"{a}-{s+1}" for i, a in enumerate(input)
|
||||
] # add number to duplicates
|
||||
return input
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ class SvIfcCreateProject(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helpe
|
||||
self.outputs.new("SvVerticesSocket", "file")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
op = layout.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = "Adds project, unit and context to IFC file"
|
||||
op = layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Adds project, unit and context to IFC file"
|
||||
)
|
||||
# op.tooltip = self.tooltip
|
||||
|
||||
def process(self):
|
||||
|
||||
@@ -54,9 +54,9 @@ class SvIfcCreateShape(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
row = layout.row(align=True)
|
||||
row.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = "Create Blender shape from IfcEntity Id. Takes one or multiple IfcEntity IDs."
|
||||
row.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Create Blender shape from IfcEntity Id. Takes one or multiple IfcEntity IDs."
|
||||
)
|
||||
row.prop(self, "refresh_local", icon="FILE_REFRESH")
|
||||
|
||||
def process(self):
|
||||
|
||||
@@ -26,9 +26,7 @@ from sverchok.node_tree import SverchCustomTreeNode
|
||||
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 Ids", update=updateNode)
|
||||
@@ -40,30 +38,22 @@ class SvIfcGetAttribute(
|
||||
|
||||
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 = (
|
||||
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_input_ids = flatten_data(
|
||||
self.inputs["entity"].sv_get(), target_level=1
|
||||
)
|
||||
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
|
||||
]
|
||||
entity_nested_inputs = [self.file.by_id(int(step_id)) for step_id in entity_nested_input_ids]
|
||||
except Exception as e:
|
||||
raise Exception("Instance ID not found", e)
|
||||
attribute_name = self.inputs["attribute_name"].sv_get()[0][0]
|
||||
|
||||
@@ -26,9 +26,7 @@ from sverchok.node_tree import SverchCustomTreeNode
|
||||
from sverchok.data_structure import updateNode, flatten_data
|
||||
|
||||
|
||||
class SvIfcGetProperty(
|
||||
bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore
|
||||
):
|
||||
class SvIfcGetProperty(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
|
||||
bl_idname = "SvIfcGetProperty"
|
||||
bl_label = "IFC Get Property"
|
||||
entity: StringProperty(name="Entity Ids", update=updateNode)
|
||||
@@ -50,9 +48,7 @@ class SvIfcGetProperty(
|
||||
self.outputs.new("SvStringsSocket", "value")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = (
|
||||
layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Get the value of a property of an IfcEntity. Can take multiple entity ids."
|
||||
)
|
||||
|
||||
@@ -72,9 +68,7 @@ class SvIfcGetProperty(
|
||||
self.value_out = []
|
||||
for entity in self.entities:
|
||||
try:
|
||||
self.value_out.append(
|
||||
ifcopenshell.util.element.get_psets(entity)[pset_name][prop_name]
|
||||
)
|
||||
self.value_out.append(ifcopenshell.util.element.get_psets(entity)[pset_name][prop_name])
|
||||
except:
|
||||
pass
|
||||
self.outputs["value"].sv_set(self.value_out)
|
||||
|
||||
@@ -60,9 +60,9 @@ class SvIfcQuickProjectSetup(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.h
|
||||
self.outputs.new("SvVerticesSocket", "file")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
op = layout.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = "Quick Project Setup: creates Ifc file and sets up a basic project"
|
||||
op = layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Quick Project Setup: creates Ifc file and sets up a basic project"
|
||||
)
|
||||
# op.tooltip = self.tooltip
|
||||
|
||||
def process(self):
|
||||
|
||||
@@ -25,9 +25,7 @@ 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
|
||||
):
|
||||
class SvIfcReadEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
|
||||
bl_idname = "SvIfcReadEntity"
|
||||
bl_label = "IFC Read Entity"
|
||||
entity: StringProperty(name="Entity Id", update=updateNode)
|
||||
@@ -39,9 +37,7 @@ class SvIfcReadEntity(
|
||||
self.outputs.new("SvStringsSocket", "is_a")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = (
|
||||
layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Decompose an IfcEntity into its attributes. Takes one entity id as input"
|
||||
)
|
||||
|
||||
|
||||
@@ -30,9 +30,7 @@ from sverchok.node_tree import SverchCustomTreeNode
|
||||
from sverchok.data_structure import updateNode, ensure_min_nesting
|
||||
|
||||
|
||||
class SvIfcSverchokToIfcRepr(
|
||||
bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore
|
||||
):
|
||||
class SvIfcSverchokToIfcRepr(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
|
||||
"""
|
||||
Triggers: Sv to Ifc Repr
|
||||
Tooltip: Sverchok geometry to Ifc Shape Representation
|
||||
@@ -85,9 +83,7 @@ class SvIfcSverchokToIfcRepr(
|
||||
|
||||
def sv_init(self, context):
|
||||
self.inputs.new("SvStringsSocket", "context_type").prop_name = "context_type"
|
||||
self.inputs.new(
|
||||
"SvStringsSocket", "context_identifier"
|
||||
).prop_name = "context_identifier"
|
||||
self.inputs.new("SvStringsSocket", "context_identifier").prop_name = "context_identifier"
|
||||
self.inputs.new("SvStringsSocket", "target_view").prop_name = "target_view"
|
||||
self.inputs.new("SvVerticesSocket", "Vertices")
|
||||
self.inputs.new("SvStringsSocket", "Edges")
|
||||
@@ -97,9 +93,9 @@ class SvIfcSverchokToIfcRepr(
|
||||
self.node_dict[hash(self)] = {}
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
op = layout.operator(
|
||||
"node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False
|
||||
).tooltip = "Sverchok geometry to Ifc Shape Representation. \nTakes one or multiple geometries."
|
||||
op = layout.operator("node.sv_ifc_tooltip", text="", icon="QUESTION", emboss=False).tooltip = (
|
||||
"Sverchok geometry to Ifc Shape Representation. \nTakes one or multiple geometries."
|
||||
)
|
||||
|
||||
def process(self):
|
||||
if not any(socket.is_linked for socket in self.inputs):
|
||||
@@ -108,9 +104,7 @@ class SvIfcSverchokToIfcRepr(
|
||||
self.sv_input_names = [i.name for i in self.inputs]
|
||||
|
||||
if hash(self) not in self.node_dict:
|
||||
self.node_dict[
|
||||
hash(self)
|
||||
] = {} # happens if node is already on canvas when blender loads
|
||||
self.node_dict[hash(self)] = {} # happens if node is already on canvas when blender loads
|
||||
if not self.node_dict[hash(self)]:
|
||||
self.node_dict[hash(self)].update(dict.fromkeys(self.sv_input_names, 0))
|
||||
|
||||
@@ -124,9 +118,7 @@ class SvIfcSverchokToIfcRepr(
|
||||
edit = True
|
||||
self.node_dict[hash(self)][self.inputs[i].name] = input
|
||||
|
||||
self.vertices = ensure_min_nesting(
|
||||
self.inputs["Vertices"].sv_get(deepcopy=False), 4
|
||||
)
|
||||
self.vertices = ensure_min_nesting(self.inputs["Vertices"].sv_get(deepcopy=False), 4)
|
||||
self.edges = ensure_min_nesting(self.inputs["Edges"].sv_get(deepcopy=False), 4)
|
||||
self.faces = ensure_min_nesting(self.inputs["Faces"].sv_get(deepcopy=False), 4)
|
||||
data = list(zip(self.vertices, self.edges, self.faces))
|
||||
@@ -160,14 +152,12 @@ class SvIfcSverchokToIfcRepr(
|
||||
faces=[list(map(tuple, item[2]))],
|
||||
)
|
||||
if not representation:
|
||||
raise Exception(
|
||||
"Couldn't create representation. Possibly wrong context."
|
||||
)
|
||||
raise Exception("Couldn't create representation. Possibly wrong context.")
|
||||
representations_ids_obj.append([representation.id()])
|
||||
representations_ids.append(representations_ids_obj)
|
||||
SvIfcStore.id_map.setdefault(self.node_id, {}).setdefault(
|
||||
"Representations", []
|
||||
).append(representations_ids_obj)
|
||||
SvIfcStore.id_map.setdefault(self.node_id, {}).setdefault("Representations", []).append(
|
||||
representations_ids_obj
|
||||
)
|
||||
return representations_ids
|
||||
|
||||
def edit(self):
|
||||
@@ -188,13 +178,9 @@ class SvIfcSverchokToIfcRepr(
|
||||
self.file, self.context_type, self.context_identifier, self.target_view
|
||||
)
|
||||
if not context:
|
||||
parent = ifcopenshell.util.representation.get_context(
|
||||
self.file, self.context_type
|
||||
)
|
||||
parent = ifcopenshell.util.representation.get_context(self.file, self.context_type)
|
||||
if not parent:
|
||||
parent = ifcopenshell.api.run(
|
||||
"context.add_context", self.file, context_type=self.context_type
|
||||
)
|
||||
parent = ifcopenshell.api.run("context.add_context", self.file, context_type=self.context_type)
|
||||
context = ifcopenshell.api.run(
|
||||
"context.add_context",
|
||||
self.file,
|
||||
@@ -203,9 +189,7 @@ class SvIfcSverchokToIfcRepr(
|
||||
target_view=self.target_view,
|
||||
parent=parent,
|
||||
)
|
||||
SvIfcStore.id_map.setdefault(self.node_id, {}).setdefault(
|
||||
"Contexts", []
|
||||
).append(context.id())
|
||||
SvIfcStore.id_map.setdefault(self.node_id, {}).setdefault("Contexts", []).append(context.id())
|
||||
return context
|
||||
|
||||
def sv_free(self):
|
||||
@@ -225,14 +209,10 @@ class SvIfcSverchokToIfcRepr(
|
||||
if not self.file.get_inverse(context):
|
||||
if self.file.by_id(context_id).ParentContext:
|
||||
parent = self.file.by_id(context_id).ParentContext
|
||||
ifcopenshell.api.run(
|
||||
"context.remove_context", self.file, context=context
|
||||
)
|
||||
ifcopenshell.api.run("context.remove_context", self.file, context=context)
|
||||
if parent:
|
||||
if not self.file.get_inverse(parent):
|
||||
ifcopenshell.api.run(
|
||||
"context.remove_context", self.file, context=parent
|
||||
)
|
||||
ifcopenshell.api.run("context.remove_context", self.file, context=parent)
|
||||
# print("Removed context with step ID: ", context_id)
|
||||
SvIfcStore.id_map[self.node_id]["Contexts"].remove(context_id)
|
||||
del SvIfcStore.id_map[self.node_id]
|
||||
|
||||
Reference in New Issue
Block a user