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
+24
View File
@@ -8,3 +8,27 @@ IfcSverchok is packaged like a regular Blender add-on, so installation is the sa
Like all Blender add-ons, they can be installed using `Edit > Preferences > Addons > Install > Choose Downloaded ZIP > Enable Add-on Checkbox`. You can enable add-ons permanently by using `Save User Settings` from the Addons menu.
Before installing, you will also need to [install the BlenderBIM Add-on](https://blenderbim.org/docs-python/blenderbim/installation) and [install Sverchok](https://github.com/nortikin/sverchok#installation).
## Nodes
List of nodes (nodes not listed here are not concidered ready for use). If you find bugs/unexpected behaviour in any of them, please open an issue or get in touch otherwise.
| Node name | Inputs | Outputs | Description |
|--------------------------|-----------------------------------------------------------------------------------|---------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| IFC Create Entity | - Names<br /> - Descriptions<br /> - IfcClass<br /> - Representations<br /> - Locations<br /> - Properties | - Entities Ids | Create IFC Entity. Takes one or multiple inputs.<br /> If 'Representation(s)' is given, that determines number of output entities. Otherwise, 'Names' is used. |
| IFC Read Entity | - Entity Id | - Id<br /> - is_a<br /> - Other entity attributes (dynamic) | Decompose an IfcEntity into its attributes. Takes one entity id as input, returns attribute values. |
| IFC BMesh to IFC Repr | - Context type<br /> - Context identifier<br /> - Target View<br /> - Blender Objects | - Representations<br /> - Locations | Blender mesh to IfcShapeRepresentation. Takes one or multiple geometries.<br /> Deconstructs joined geometries and creates a separate representation for each. |
| IFC Sverchok to IFC Repr | - Context type<br /> - Context identifier<br /> - Target View<br /> - Vertices<br /> - Edges<br /> - Faces | - Representations | Sverchok geometry to IfcShapeRepresentation. Takes one or multiple nested lists of inputs. |
| IFC Create Blender Shape | - Entity Id(s) | - Blender Object(s) | Create Blender shape from IfcEntity Id. Takes one or multiple IfcEntity Ids.<br /> Creates shapes in scene and returns them in output socket. |
| IFC Add Spatial Element | - Names<br /> - IfcClass<br /> - Elements | - Entity Id(s) | Add IfcElements to an IfcSpatialElement. Takes one or multiple nested lists of inputs.<br /> Input can also be a (list of) spacial elements to be aggregated. |
| IFC Write File | - path | | Writes active Ifc model to path. <br />N.B.! It's recommended to use the 'Write File' panel under the "IfcSverchok" tab instead. |
| IFC Class Picker | - IfcProduct (from drop-down)<br /> - IfcClass (from drop-down) | - IfcClass | Pick an IfcClass from drop-down list. |
| IFC By Id | - Id | - Entities | Get IfcElement by step id. Takes one or multiple step ids. |
| IFC By Guid | - Guid | - Entities | Get IfcElement by guid. Takes one or multiple guids. |
| IFC By Type | - IfcProduct (from drop-down)<br /> - IfcClass (from drop-down)<br /> - Custom IfcClass | - Entities<br /> - Entity Ids | Get IFC element(s) in file by type. Pick an IfcProduct and an IfcClass or give a custom IfcClass. |
| IFC Add Pset | - Name<br /> - Properties<br /> - Element Ids | - (Pset) Entities | Add a property set and corresponding properties, in a JSON key:value format, to IfcElements. |
| IFC Generate Guid | | - Guid | Generate a unique GUID. |
| IFC Get Property | - Entity Ids<br /> - Pset name<br /> - Prop name | - Value | Get the value of a property of an IfcEntity. Can take multiple entity ids. |
| IFC Get Attribute | - Entity Ids<br /> - Attribute Name | - Value | Get the value of an attribute of an IfcEntity. Can take multiple entities. |
### IfcSverchok panel
IfcSverchok creates a "IfcSverchok" tab in the Nodes panel. It includes a "Re-run all nodes" button that creates a fresh IFC File and a "Write File" button. It's recommended to re-run all nodes before saving the file either through the panel or the "Write File" node.
-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: