Updated by_query and removed print statements

This commit is contained in:
martinaCodes
2022-11-11 12:52:06 +01:00
committed by Dion Moult
parent 05633cd657
commit 6e5f2f3f8d
8 changed files with 41 additions and 35 deletions
-8
View File
@@ -70,7 +70,6 @@ class SvIfcAddPset(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIf
self.file = SvIfcStore.get_file()
try:
elements = [self.file.by_id(int(step_id)) for step_id in element_ids]
print(elements[0])
except Exception as e:
raise Exception("Instance ID not found", e)
@@ -84,7 +83,6 @@ class SvIfcAddPset(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIf
def create(self, name, properties, elements):
results = []
for element in elements:
print("element: ", element)
result = ifcopenshell.api.run(
"pset.add_pset", self.file, product=element, name=name
)
@@ -94,7 +92,6 @@ class SvIfcAddPset(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIf
pset=result,
properties=json.loads(properties),
)
print("result: ", result)
SvIfcStore.id_map.setdefault(self.node_id, []).append(result.id())
results.append(result)
return results
@@ -114,11 +111,6 @@ class SvIfcAddPset(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIf
results.append(result)
return results
# def get_existing_element(self):
# entity_id = list(SvIfcStore.id_map.keys())[list(SvIfcStore.id_map.values()).index(self.node_id)]
# return self.file.by_id(entity_id)
def register():
bpy.utils.register_class(SvIfcAddPset)
+8 -5
View File
@@ -58,7 +58,7 @@ class SvIfcBMeshToIfcRepr(
def refresh_node(self, context):
if self.refresh_local:
updateNode(self, context)
self.process()
self.refresh_local = False
refresh_local: BoolProperty(
@@ -181,14 +181,16 @@ class SvIfcBMeshToIfcRepr(
if blender_object.type == "MESH":
try:
bpy.ops.object.mode_set(mode="OBJECT")
except:
except Exception as e:
print(e)
pass
bpy.ops.object.select_all(action="DESELECT")
blender_object.select_set(True)
try:
bpy.ops.object.mode_set(mode="EDIT")
except:
except Exception as e:
print(e)
pass
blender_object.select_set(True)
bpy.ops.mesh.separate(type="LOOSE")
representations_ids_obj = []
locations_obj = []
@@ -218,7 +220,8 @@ class SvIfcBMeshToIfcRepr(
).append(locations_obj)
try:
bpy.ops.object.mode_set(mode="OBJECT")
except:
except Exception as e:
print(e)
pass
bpy.ops.object.select_all(action="DESELECT")
return representations_ids, locations
-8
View File
@@ -44,14 +44,6 @@ class SvIfcByGuid(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfc
).tooltip = "Get IFC element by guid. Takes one or multiple guids."
def process(self):
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)
self.guids = flatten_data(self.inputs["guid"].sv_get(), target_level=1)
if not self.guids[0]:
return
+9 -7
View File
@@ -20,6 +20,7 @@ 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
@@ -28,21 +29,22 @@ from sverchok.data_structure import updateNode
class SvIfcByQuery(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = "SvIfcByQuery"
bl_label = "IFC By Query"
file: StringProperty(name="file", update=updateNode)
query: StringProperty(name="query", update=updateNode)
query: StringProperty(name="Query", update=updateNode)
def sv_init(self, context):
self.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "query").prop_name = "query"
self.outputs.new("SvStringsSocket", "entity")
self.outputs.new("SvStringsSocket", "Entity")
def process(self):
self.sv_input_names = ["file", "query"]
if not self.inputs["query"].sv_get()[0][0]:
return
self.file = SvIfcStore.get_file()
self.sv_input_names = ["query"]
super().process()
def process_ifc(self, file, query):
def process_ifc(self, query):
selector = ifcopenshell.util.selector.Selector()
self.outputs["entity"].sv_set([selector.parse(file, query)])
self.outputs["Entity"].sv_set([selector.parse(self.file, query)])
def register():
@@ -180,11 +180,8 @@ class SvIfcCreateEntity(
name=self.names[i],
description=self.descriptions[i],
)
print("Entity: ", entity)
try:
print("Representations: ", self.representations[i])
for repr in self.representations[i]:
print("Representation: ", repr)
if repr:
ifcopenshell.api.run(
"geometry.assign_representation",
@@ -196,7 +193,6 @@ class SvIfcCreateEntity(
pass
try:
for loc in self.locations[i]:
print("Location: ", loc)
if isinstance(loc, Matrix):
ifcopenshell.api.run(
"geometry.edit_object_placement",
@@ -64,7 +64,6 @@ class SvIfcGetAttribute(
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]
-2
View File
@@ -47,9 +47,7 @@ class SvIfcReadEntity(
def process(self):
self.sv_input_names = ["entity"]
# ifc_class = ensure_min_nesting(self.inputs["entity"].sv_get(), 1)
entity_id = flatten_data(self.inputs["entity"].sv_get(), target_level=1)
print("entity_id", entity_id)
if not entity_id[0]:
return
if len(entity_id) > 1: