black ifcsverchok

This commit is contained in:
htlcnn
2020-11-01 19:24:01 +07:00
committed by Dion Moult
parent 4a6ec11f6f
commit 2c9d6a47f4
18 changed files with 245 additions and 203 deletions
+37 -26
View File
@@ -21,25 +21,32 @@ from sverchok.utils.extra_categories import register_extra_category_provider, un
from sverchok.ui.nodeview_space_menu import make_extra_category_menus
from sverchok.utils.logging import info, debug
def nodes_index():
return [("IFC", [
("ifc.create_file", "SvIfcCreateFile"),
("ifc.read_file", "SvIfcReadFile"),
("ifc.write_file", "SvIfcWriteFile"),
("ifc.create_entity", "SvIfcCreateEntity"),
("ifc.create_shape", "SvIfcCreateShape"),
("ifc.read_entity", "SvIfcReadEntity"),
("ifc.by_id", "SvIfcById"),
("ifc.by_guid", "SvIfcByGuid"),
("ifc.by_type", "SvIfcByType"),
("ifc.by_query", "SvIfcByQuery"),
("ifc.add", "SvIfcAdd"),
("ifc.remove", "SvIfcRemove"),
("ifc.generate_guid", "SvIfcGenerateGuid"),
("ifc.get_property", "SvIfcGetProperty"),
("ifc.get_attribute", "SvIfcGetAttribute"),
("ifc.select_blender_objects", "SvIfcSelectBlenderObjects"),
])]
return [
(
"IFC",
[
("ifc.create_file", "SvIfcCreateFile"),
("ifc.read_file", "SvIfcReadFile"),
("ifc.write_file", "SvIfcWriteFile"),
("ifc.create_entity", "SvIfcCreateEntity"),
("ifc.create_shape", "SvIfcCreateShape"),
("ifc.read_entity", "SvIfcReadEntity"),
("ifc.by_id", "SvIfcById"),
("ifc.by_guid", "SvIfcByGuid"),
("ifc.by_type", "SvIfcByType"),
("ifc.by_query", "SvIfcByQuery"),
("ifc.add", "SvIfcAdd"),
("ifc.remove", "SvIfcRemove"),
("ifc.generate_guid", "SvIfcGenerateGuid"),
("ifc.get_property", "SvIfcGetProperty"),
("ifc.get_attribute", "SvIfcGetAttribute"),
("ifc.select_blender_objects", "SvIfcSelectBlenderObjects"),
],
)
]
def make_node_list():
modules = []
@@ -51,28 +58,32 @@ def make_node_list():
modules.append(module)
return modules
imported_modules = make_node_list()
reload_event = False
import bpy
def register_nodes():
node_modules = make_node_list()
for module in node_modules:
module.register()
info("Registered %s nodes", len(node_modules))
def unregister_nodes():
global imported_modules
for module in reversed(imported_modules):
module.unregister()
def make_menu():
menu = []
index = nodes_index()
for category, items in index:
identifier = "IFCSVERCHOK_" + category.replace(' ', '_')
identifier = "IFCSVERCHOK_" + category.replace(" ", "_")
node_items = []
for item in items:
nodetype = item[1]
@@ -83,14 +94,11 @@ def make_menu():
node_item = SverchNodeItem.new(nodetype)
node_items.append(node_item)
if node_items:
cat = SverchNodeCategory(
identifier,
category,
items=node_items
)
cat = SverchNodeCategory(identifier, category, items=node_items)
menu.append(cat)
return menu
class SvExCategoryProvider(object):
def __init__(self, identifier, menu):
self.identifier = identifier
@@ -99,8 +107,10 @@ class SvExCategoryProvider(object):
def get_categories(self):
return self.menu
our_menu_classes = []
def register():
global our_menu_classes
@@ -111,13 +121,14 @@ def register():
auto_gather_node_classes(extra_nodes)
menu = make_menu()
menu_category_provider = SvExCategoryProvider("IFCSVERCHOK", menu)
register_extra_category_provider(menu_category_provider) #if 'IFCSVERCHOK' in nodeitems_utils._node_categories:
register_extra_category_provider(menu_category_provider) # if 'IFCSVERCHOK' in nodeitems_utils._node_categories:
nodeitems_utils.register_node_categories("IFCSVERCHOK", menu)
our_menu_classes = make_extra_category_menus()
def unregister():
global our_menu_classes
if 'IFCSVERCHOK' in nodeitems_utils._node_categories:
if "IFCSVERCHOK" in nodeitems_utils._node_categories:
nodeitems_utils.unregister_node_categories("IFCSVERCHOK")
for clazz in our_menu_classes:
try:
+2 -1
View File
@@ -3,7 +3,8 @@ from sverchok.data_structure import zip_long_repeat
ifc_files = {}
class SvIfcCore():
class SvIfcCore:
def process(self):
sv_inputs_nested = []
for name in self.sv_input_names:
+13 -11
View File
@@ -7,31 +7,33 @@ from sverchok.data_structure import updateNode
class SvIfcAdd(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcAdd'
bl_label = 'IFC Add'
file: StringProperty(name='file', update=updateNode)
entity: StringProperty(name='entity', update=updateNode)
bl_idname = "SvIfcAdd"
bl_label = "IFC Add"
file: StringProperty(name="file", update=updateNode)
entity: StringProperty(name="entity", update=updateNode)
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'file').prop_name = 'file'
self.inputs.new('SvStringsSocket', 'entity').prop_name = 'entity'
self.outputs.new('SvStringsSocket', 'file')
self.outputs.new('SvStringsSocket', 'entity')
self.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "entity").prop_name = "entity"
self.outputs.new("SvStringsSocket", "file")
self.outputs.new("SvStringsSocket", "entity")
def process(self):
self.sv_input_names = ['file', 'entity']
self.sv_input_names = ["file", "entity"]
self.file_out = []
self.entity_out = []
super().process()
self.outputs['file'].sv_set([self.file_out])
self.outputs['entity'].sv_set([self.entity_out])
self.outputs["file"].sv_set([self.file_out])
self.outputs["entity"].sv_set([self.entity_out])
def process_ifc(self, file, entity):
self.entity_out.append(file.add(entity))
self.file_out.append(file)
def register():
bpy.utils.register_class(SvIfcAdd)
def unregister():
bpy.utils.unregister_class(SvIfcAdd)
+11 -9
View File
@@ -7,25 +7,27 @@ from sverchok.data_structure import updateNode
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)
bl_idname = "SvIfcByGuid"
bl_label = "IFC By Guid"
file: StringProperty(name="file", update=updateNode)
guid: StringProperty(name="guid", update=updateNode)
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.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "guid").prop_name = "guid"
self.outputs.new("SvStringsSocket", "entity")
def process(self):
self.sv_input_names = ['file', 'guid']
self.sv_input_names = ["file", "guid"]
super().process()
def process_ifc(self, file, guid):
self.outputs['entity'].sv_set([[file.by_guid(guid)]])
self.outputs["entity"].sv_set([[file.by_guid(guid)]])
def register():
bpy.utils.register_class(SvIfcByGuid)
def unregister():
bpy.utils.unregister_class(SvIfcByGuid)
+11 -9
View File
@@ -7,25 +7,27 @@ from sverchok.data_structure import updateNode
class SvIfcById(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcById'
bl_label = 'IFC By Id'
file: StringProperty(name='file', update=updateNode)
id: StringProperty(name='id', update=updateNode)
bl_idname = "SvIfcById"
bl_label = "IFC By Id"
file: StringProperty(name="file", update=updateNode)
id: StringProperty(name="id", update=updateNode)
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'file').prop_name = 'file'
self.inputs.new('SvStringsSocket', 'id').prop_name = 'id'
self.outputs.new('SvStringsSocket', 'entity')
self.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "id").prop_name = "id"
self.outputs.new("SvStringsSocket", "entity")
def process(self):
self.sv_input_names = ['file', 'id']
self.sv_input_names = ["file", "id"]
super().process()
def process_ifc(self, file, id):
self.outputs['entity'].sv_set([[file.by_id(int(id))]])
self.outputs["entity"].sv_set([[file.by_id(int(id))]])
def register():
bpy.utils.register_class(SvIfcById)
def unregister():
bpy.utils.unregister_class(SvIfcById)
+11 -9
View File
@@ -8,26 +8,28 @@ 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)
bl_idname = "SvIfcByQuery"
bl_label = "IFC By Query"
file: StringProperty(name="file", 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.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "query").prop_name = "query"
self.outputs.new("SvStringsSocket", "entity")
def process(self):
self.sv_input_names = ['file', 'query']
self.sv_input_names = ["file", "query"]
super().process()
def process_ifc(self, file, query):
selector = ifcopenshell.util.selector.Selector()
self.outputs['entity'].sv_set([selector.parse(file, query)])
self.outputs["entity"].sv_set([selector.parse(file, query)])
def register():
bpy.utils.register_class(SvIfcByQuery)
def unregister():
bpy.utils.unregister_class(SvIfcByQuery)
+11 -9
View File
@@ -7,25 +7,27 @@ from sverchok.data_structure import updateNode
class SvIfcByType(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcByType'
bl_label = 'IFC By Type'
file: StringProperty(name='file', update=updateNode)
type: StringProperty(name='type', update=updateNode)
bl_idname = "SvIfcByType"
bl_label = "IFC By Type"
file: StringProperty(name="file", update=updateNode)
type: StringProperty(name="type", update=updateNode)
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'file').prop_name = 'file'
self.inputs.new('SvStringsSocket', 'type').prop_name = 'type'
self.outputs.new('SvStringsSocket', 'entity')
self.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "type").prop_name = "type"
self.outputs.new("SvStringsSocket", "entity")
def process(self):
self.sv_input_names = ['file', 'type']
self.sv_input_names = ["file", "type"]
super().process()
def process_ifc(self, file, type):
self.outputs['entity'].sv_set([file.by_type(type)])
self.outputs["entity"].sv_set([file.by_type(type)])
def register():
bpy.utils.register_class(SvIfcByType)
def unregister():
bpy.utils.unregister_class(SvIfcByType)
+27 -22
View File
@@ -7,27 +7,27 @@ from sverchok.data_structure import updateNode
class SvIfcCreateEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcCreateEntity'
bl_label = 'IFC Create Entity'
file: StringProperty(name='file', update=updateNode)
ifc_class: StringProperty(name='ifc_class', update=updateNode)
current_ifc_class: StringProperty(name='current_ifc_class')
bl_idname = "SvIfcCreateEntity"
bl_label = "IFC Create Entity"
file: StringProperty(name="file", update=updateNode)
ifc_class: StringProperty(name="ifc_class", update=updateNode)
current_ifc_class: StringProperty(name="current_ifc_class")
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'file').prop_name = 'file'
self.inputs.new('SvStringsSocket', 'ifc_class').prop_name = 'ifc_class'
self.outputs.new('SvStringsSocket', 'file')
self.outputs.new('SvStringsSocket', 'entity')
self.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "ifc_class").prop_name = "ifc_class"
self.outputs.new("SvStringsSocket", "file")
self.outputs.new("SvStringsSocket", "entity")
def process(self):
self.sv_input_names = ['file', 'ifc_class']
ifc_class = self.inputs['ifc_class'].sv_get()[0][0]
self.sv_input_names = ["file", "ifc_class"]
ifc_class = self.inputs["ifc_class"].sv_get()[0][0]
if ifc_class:
file = self.inputs['file'].sv_get()[0][0]
file = self.inputs["file"].sv_get()[0][0]
if file:
schema_name = file.wrapped_data.schema
else:
schema_name = 'IFC4'
schema_name = "IFC4"
self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name)
self.entity_schema = self.schema.declaration_by_name(ifc_class)
@@ -50,7 +50,7 @@ class SvIfcCreateEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper
for i in range(0, self.entity_schema.attribute_count()):
name = self.entity_schema.attribute_by_index(i).name()
setattr(SvIfcCreateEntity, name, StringProperty(name=name))
self.inputs.new('SvStringsSocket', name).prop_name = name
self.inputs.new("SvStringsSocket", name).prop_name = name
self.current_ifc_class = ifc_class
def process_ifc(self, file, ifc_class, *attributes):
@@ -58,35 +58,40 @@ class SvIfcCreateEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper
for i in range(0, len(entity)):
try:
value = attributes[i]
if isinstance(value, str) and value == '':
if isinstance(value, str) and value == "":
value = None
except:
value = None
if value is None and entity.is_a('IfcRoot') and i==0:
if value is None and entity.is_a("IfcRoot") and i == 0:
value = ifcopenshell.guid.new()
if value is not None:
value = self.cast_value(self.entity_schema.attribute_by_index(i), value)
try:
entity[i] = value
except:
raise Exception('The IFC class {} requires a valid value for {} - you provided {}'.format(
ifc_class, entity.attribute_name(i), value))
self.outputs['file'].sv_set([[file]])
self.outputs['entity'].sv_set([[entity]])
raise Exception(
"The IFC class {} requires a valid value for {} - you provided {}".format(
ifc_class, entity.attribute_name(i), value
)
)
self.outputs["file"].sv_set([[file]])
self.outputs["entity"].sv_set([[entity]])
def cast_value(self, attribute, value):
data_type = self.get_attribute_data_type(attribute.type_of_attribute())
if data_type == 'integer':
if data_type == "integer":
value = int(value)
return value
def get_attribute_data_type(self, data_type):
if hasattr(data_type, 'declared_type'):
if hasattr(data_type, "declared_type"):
return self.get_attribute_data_type(data_type.declared_type())
return data_type
def register():
bpy.utils.register_class(SvIfcCreateEntity)
def unregister():
bpy.utils.unregister_class(SvIfcCreateEntity)
+14 -12
View File
@@ -10,41 +10,43 @@ class SvIfcCreateFileRefresh(bpy.types.Operator):
bl_idname = "node.sv_ifc_create_file_refresh"
bl_label = "LB Out"
idtree: StringProperty(default='')
idname: StringProperty(default='')
has_baked: bpy.props.BoolProperty(name='Has Baked', default=False)
idtree: StringProperty(default="")
idname: StringProperty(default="")
has_baked: bpy.props.BoolProperty(name="Has Baked", default=False)
def execute(self, context):
node = bpy.data.node_groups[self.idtree].nodes[self.idname]
node.process()
return {'FINISHED'}
return {"FINISHED"}
class SvIfcCreateFile(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcCreateFile'
bl_label = 'IFC Create File'
schema: StringProperty(name='schema', update=updateNode, default='IFC4')
bl_idname = "SvIfcCreateFile"
bl_label = "IFC Create File"
schema: StringProperty(name="schema", update=updateNode, default="IFC4")
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'schema').prop_name = 'schema'
self.outputs.new('SvVerticesSocket', 'file')
self.inputs.new("SvStringsSocket", "schema").prop_name = "schema"
self.outputs.new("SvVerticesSocket", "file")
def draw_buttons(self, context, layout):
self.wrapper_tracked_ui_draw_op(layout, 'node.sv_ifc_create_file_refresh', icon='FILE_REFRESH', text='Refresh')
self.wrapper_tracked_ui_draw_op(layout, "node.sv_ifc_create_file_refresh", icon="FILE_REFRESH", text="Refresh")
def process(self):
self.sv_input_names = ['schema']
self.sv_input_names = ["schema"]
super().process()
def process_ifc(self, schema):
guid = ifcopenshell.guid.new()
ifcsverchok.helper.ifc_files[guid] = ifcopenshell.file(schema=schema)
self.outputs['file'].sv_set([[ifcsverchok.helper.ifc_files[guid]]])
self.outputs["file"].sv_set([[ifcsverchok.helper.ifc_files[guid]]])
def register():
bpy.utils.register_class(SvIfcCreateFile)
bpy.utils.register_class(SvIfcCreateFileRefresh)
def unregister():
bpy.utils.unregister_class(SvIfcCreateFile)
bpy.utils.unregister_class(SvIfcCreateFileRefresh)
+18 -17
View File
@@ -11,55 +11,56 @@ from sverchok.data_structure import updateNode
class SvIfcCreateShapeRefresh(bpy.types.Operator):
bl_idname = "node.sv_ifc_create_shape_refresh"
bl_label = "IFC Create Shape Refresh"
bl_options = {'UNDO'}
bl_options = {"UNDO"}
idtree: StringProperty(default='')
idname: StringProperty(default='')
idtree: StringProperty(default="")
idname: StringProperty(default="")
def execute(self, context):
node = bpy.data.node_groups[self.idtree].nodes[self.idname]
node.process()
return {'FINISHED'}
return {"FINISHED"}
class SvIfcCreateShape(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcCreateShape'
bl_label = 'IFC Create Shape'
file: StringProperty(name='file', update=updateNode)
entity: StringProperty(name='entity', update=updateNode)
bl_idname = "SvIfcCreateShape"
bl_label = "IFC Create Shape"
file: StringProperty(name="file", update=updateNode)
entity: StringProperty(name="entity", update=updateNode)
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'file').prop_name = 'file'
self.inputs.new('SvStringsSocket', 'entity').prop_name = 'entity'
self.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "entity").prop_name = "entity"
def draw_buttons(self, context, layout):
self.wrapper_tracked_ui_draw_op(layout, 'node.sv_ifc_create_shape_refresh', icon='FILE_REFRESH', text='Refresh')
self.wrapper_tracked_ui_draw_op(layout, "node.sv_ifc_create_shape_refresh", icon="FILE_REFRESH", text="Refresh")
def process(self):
self.sv_input_names = ['file', 'entity']
self.sv_input_names = ["file", "entity"]
super().process()
def process_ifc(self, file, entity):
try:
if not entity.is_a('IfcProduct'):
if not entity.is_a("IfcProduct"):
return
logger = logging.getLogger('ImportIFC')
self.ifc_import_settings = blenderbim.bim.import_ifc.IfcImportSettings.factory(bpy.context, '', logger)
logger = logging.getLogger("ImportIFC")
self.ifc_import_settings = blenderbim.bim.import_ifc.IfcImportSettings.factory(bpy.context, "", logger)
settings = ifcopenshell.geom.settings()
shape = ifcopenshell.geom.create_shape(settings, entity)
ifc_importer = blenderbim.bim.import_ifc.IfcImporter(self.ifc_import_settings)
ifc_importer.file = file
mesh = ifc_importer.create_mesh(entity, shape)
obj = bpy.data.objects.new('IFC Element', mesh)
obj = bpy.data.objects.new("IFC Element", mesh)
bpy.context.scene.collection.objects.link(obj)
except:
print('Entity could not be converted into a shape', entity)
print("Entity could not be converted into a shape", entity)
def register():
bpy.utils.register_class(SvIfcCreateShapeRefresh)
bpy.utils.register_class(SvIfcCreateShape)
def unregister():
bpy.utils.unregister_class(SvIfcCreateShape)
bpy.utils.unregister_class(SvIfcCreateShapeRefresh)
+5 -4
View File
@@ -7,18 +7,19 @@ from sverchok.data_structure import updateNode
class SvIfcGenerateGuid(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcGenerateGuid'
bl_label = 'IFC Generate Guid'
bl_idname = "SvIfcGenerateGuid"
bl_label = "IFC Generate Guid"
def sv_init(self, context):
self.outputs.new('SvStringsSocket', 'guid')
self.outputs.new("SvStringsSocket", "guid")
def process(self):
self.outputs['guid'].sv_set([[ifcopenshell.guid.new()]])
self.outputs["guid"].sv_set([[ifcopenshell.guid.new()]])
def register():
bpy.utils.register_class(SvIfcGenerateGuid)
def unregister():
bpy.utils.unregister_class(SvIfcGenerateGuid)
+10 -9
View File
@@ -8,21 +8,21 @@ from sverchok.data_structure import updateNode
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)
bl_idname = "SvIfcGetAttribute"
bl_label = "IFC Get Attribute"
entity: StringProperty(name="entity", update=updateNode)
attribute_name: StringProperty(name="attribute_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.outputs.new('SvStringsSocket', 'value')
self.inputs.new("SvStringsSocket", "entity").prop_name = "entity"
self.inputs.new("SvStringsSocket", "attribute_name").prop_name = "attribute_name"
self.outputs.new("SvStringsSocket", "value")
def process(self):
self.sv_input_names = ['entity', 'attribute_name']
self.sv_input_names = ["entity", "attribute_name"]
self.value_out = []
super().process()
self.outputs['value'].sv_set(self.value_out)
self.outputs["value"].sv_set(self.value_out)
def process_ifc(self, entity, attribute_name):
try:
@@ -37,5 +37,6 @@ class SvIfcGetAttribute(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper
def register():
bpy.utils.register_class(SvIfcGetAttribute)
def unregister():
bpy.utils.unregister_class(SvIfcGetAttribute)
+12 -11
View File
@@ -8,23 +8,23 @@ from sverchok.data_structure import updateNode
class SvIfcGetProperty(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcGetProperty'
bl_label = 'IFC Get Property'
entity: StringProperty(name='entity', update=updateNode)
pset_name: StringProperty(name='pset_name', update=updateNode)
prop_name: StringProperty(name='prop_name', update=updateNode)
bl_idname = "SvIfcGetProperty"
bl_label = "IFC Get Property"
entity: StringProperty(name="entity", update=updateNode)
pset_name: StringProperty(name="pset_name", update=updateNode)
prop_name: StringProperty(name="prop_name", update=updateNode)
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'entity').prop_name = 'entity'
self.inputs.new('SvStringsSocket', 'pset_name').prop_name = 'pset_name'
self.inputs.new('SvStringsSocket', 'prop_name').prop_name = 'prop_name'
self.outputs.new('SvStringsSocket', 'value')
self.inputs.new("SvStringsSocket", "entity").prop_name = "entity"
self.inputs.new("SvStringsSocket", "pset_name").prop_name = "pset_name"
self.inputs.new("SvStringsSocket", "prop_name").prop_name = "prop_name"
self.outputs.new("SvStringsSocket", "value")
def process(self):
self.sv_input_names = ['entity', 'pset_name', 'prop_name']
self.sv_input_names = ["entity", "pset_name", "prop_name"]
self.value_out = []
super().process()
self.outputs['value'].sv_set(self.value_out)
self.outputs["value"].sv_set(self.value_out)
def process_ifc(self, entity, pset_name, prop_name):
try:
@@ -36,5 +36,6 @@ class SvIfcGetProperty(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.
def register():
bpy.utils.register_class(SvIfcGetProperty)
def unregister():
bpy.utils.unregister_class(SvIfcGetProperty)
+17 -16
View File
@@ -7,28 +7,28 @@ from sverchok.data_structure import updateNode
class SvIfcReadEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcReadEntity'
bl_label = 'IFC Read Entity'
file: StringProperty(name='file', update=updateNode)
entity: StringProperty(name='entity', update=updateNode)
current_ifc_class: StringProperty(name='current_ifc_class')
bl_idname = "SvIfcReadEntity"
bl_label = "IFC Read Entity"
file: StringProperty(name="file", update=updateNode)
entity: StringProperty(name="entity", update=updateNode)
current_ifc_class: StringProperty(name="current_ifc_class")
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'file').prop_name = 'file'
self.inputs.new('SvStringsSocket', 'entity').prop_name = 'entity'
self.outputs.new('SvStringsSocket', 'id')
self.outputs.new('SvStringsSocket', 'is_a')
self.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "entity").prop_name = "entity"
self.outputs.new("SvStringsSocket", "id")
self.outputs.new("SvStringsSocket", "is_a")
def process(self):
self.sv_input_names = ['file', 'entity']
ifc_class = self.inputs['entity'].sv_get()[0][0]
self.sv_input_names = ["file", "entity"]
ifc_class = self.inputs["entity"].sv_get()[0][0]
if ifc_class:
ifc_class = ifc_class.is_a()
file = self.inputs['file'].sv_get()[0][0]
file = self.inputs["file"].sv_get()[0][0]
if file:
schema_name = file.wrapped_data.schema
else:
schema_name = 'IFC4'
schema_name = "IFC4"
self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name)
self.entity_schema = self.schema.declaration_by_name(ifc_class)
@@ -41,12 +41,12 @@ class SvIfcReadEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.S
self.outputs.remove(self.outputs[-1])
for i in range(0, self.entity_schema.attribute_count()):
name = self.entity_schema.attribute_by_index(i).name()
self.outputs.new('SvStringsSocket', name).prop_name = name
self.outputs.new("SvStringsSocket", name).prop_name = name
self.current_ifc_class = ifc_class
def process_ifc(self, file, entity):
self.outputs['id'].sv_set([[entity.id()]])
self.outputs['is_a'].sv_set([[entity.is_a()]])
self.outputs["id"].sv_set([[entity.id()]])
self.outputs["is_a"].sv_set([[entity.is_a()]])
for i in range(0, self.entity_schema.attribute_count()):
name = self.entity_schema.attribute_by_index(i).name()
self.outputs[name].sv_set([[entity[i]]])
@@ -55,5 +55,6 @@ class SvIfcReadEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.S
def register():
bpy.utils.register_class(SvIfcReadEntity)
def unregister():
bpy.utils.unregister_class(SvIfcReadEntity)
+9 -7
View File
@@ -7,25 +7,27 @@ from sverchok.data_structure import updateNode
class SvIfcReadFile(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcReadFile'
bl_label = 'IFC Read File'
path: StringProperty(name='path', update=updateNode)
bl_idname = "SvIfcReadFile"
bl_label = "IFC Read File"
path: StringProperty(name="path", update=updateNode)
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'path').prop_name = 'path'
self.outputs.new('SvVerticesSocket', 'file')
self.inputs.new("SvStringsSocket", "path").prop_name = "path"
self.outputs.new("SvVerticesSocket", "file")
def process(self):
self.sv_input_names = ['path']
self.sv_input_names = ["path"]
super().process()
def process_ifc(self, path):
guid = ifcopenshell.guid.new()
ifcsverchok.helper.ifc_files[guid] = ifcopenshell.open(path)
self.outputs['file'].sv_set([[ifcsverchok.helper.ifc_files[guid]]])
self.outputs["file"].sv_set([[ifcsverchok.helper.ifc_files[guid]]])
def register():
bpy.utils.register_class(SvIfcReadFile)
def unregister():
bpy.utils.unregister_class(SvIfcReadFile)
+12 -10
View File
@@ -7,21 +7,21 @@ from sverchok.data_structure import updateNode
class SvIfcRemove(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcRemove'
bl_label = 'IFC Remove'
file: StringProperty(name='file', update=updateNode)
entity: StringProperty(name='entity', update=updateNode)
bl_idname = "SvIfcRemove"
bl_label = "IFC Remove"
file: StringProperty(name="file", update=updateNode)
entity: StringProperty(name="entity", update=updateNode)
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'file').prop_name = 'file'
self.inputs.new('SvStringsSocket', 'entity').prop_name = 'entity'
self.outputs.new('SvStringsSocket', 'file')
self.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "entity").prop_name = "entity"
self.outputs.new("SvStringsSocket", "file")
def process(self):
file = self.inputs['file'].sv_get()[0][0]
file = self.inputs["file"].sv_get()[0][0]
self.new_file = ifcopenshell.file.from_string(file.wrapped_data.to_string())
self.remove_entity(self.inputs['entity'].sv_get())
self.outputs['file'].sv_set([[self.new_file]])
self.remove_entity(self.inputs["entity"].sv_get())
self.outputs["file"].sv_set([[self.new_file]])
def remove_entity(self, entity):
if isinstance(entity, (tuple, list)):
@@ -30,8 +30,10 @@ class SvIfcRemove(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfc
else:
self.new_file.remove(self.new_file.by_id(entity.id()))
def register():
bpy.utils.register_class(SvIfcRemove)
def unregister():
bpy.utils.unregister_class(SvIfcRemove)
@@ -10,37 +10,38 @@ from sverchok.data_structure import updateNode
class SvIfcSelectBlenderObjectsRefresh(bpy.types.Operator):
bl_idname = "node.sv_ifc_select_blender_objects_refresh"
bl_label = "IFC Select Blender Objects Refresh"
bl_options = {'UNDO'}
bl_options = {"UNDO"}
idtree: StringProperty(default='')
idname: StringProperty(default='')
idtree: StringProperty(default="")
idname: StringProperty(default="")
def execute(self, context):
node = bpy.data.node_groups[self.idtree].nodes[self.idname]
node.process()
return {'FINISHED'}
return {"FINISHED"}
class SvIfcSelectBlenderObjects(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcSelectBlenderObjects'
bl_label = 'IFC Select Blender Objects'
file: StringProperty(name='file', update=updateNode)
query: StringProperty(name='query', update=updateNode)
bl_idname = "SvIfcSelectBlenderObjects"
bl_label = "IFC Select Blender Objects"
file: StringProperty(name="file", update=updateNode)
query: StringProperty(name="query", update=updateNode)
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'entities').prop_name = 'entities'
self.inputs.new("SvStringsSocket", "entities").prop_name = "entities"
def draw_buttons(self, context, layout):
self.wrapper_tracked_ui_draw_op(layout, 'node.sv_ifc_select_blender_objects_refresh', icon='FILE_REFRESH', text='Refresh')
self.wrapper_tracked_ui_draw_op(
layout, "node.sv_ifc_select_blender_objects_refresh", icon="FILE_REFRESH", text="Refresh"
)
def process(self):
self.sv_input_names = ['entities']
self.sv_input_names = ["entities"]
self.guids = []
super().process()
for obj in bpy.context.visible_objects:
index = obj.BIMObjectProperties.attributes.find('GlobalId')
if index != -1 \
and obj.BIMObjectProperties.attributes[index].string_value in self.guids:
index = obj.BIMObjectProperties.attributes.find("GlobalId")
if index != -1 and obj.BIMObjectProperties.attributes[index].string_value in self.guids:
obj.select_set(True)
def process_ifc(self, entities):
@@ -51,6 +52,7 @@ def register():
bpy.utils.register_class(SvIfcSelectBlenderObjectsRefresh)
bpy.utils.register_class(SvIfcSelectBlenderObjects)
def unregister():
bpy.utils.unregister_class(SvIfcSelectBlenderObjects)
bpy.utils.unregister_class(SvIfcSelectBlenderObjectsRefresh)
+9 -7
View File
@@ -7,24 +7,26 @@ from sverchok.data_structure import updateNode
class SvIfcWriteFile(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
bl_idname = 'SvIfcWriteFile'
bl_label = 'IFC Write File'
file: StringProperty(name='file', update=updateNode)
path: StringProperty(name='path', update=updateNode)
bl_idname = "SvIfcWriteFile"
bl_label = "IFC Write File"
file: StringProperty(name="file", update=updateNode)
path: StringProperty(name="path", update=updateNode)
def sv_init(self, context):
self.inputs.new('SvStringsSocket', 'file').prop_name = 'file'
self.inputs.new('SvStringsSocket', 'path').prop_name = 'path'
self.inputs.new("SvStringsSocket", "file").prop_name = "file"
self.inputs.new("SvStringsSocket", "path").prop_name = "path"
def process(self):
self.sv_input_names = ['file', 'path']
self.sv_input_names = ["file", "path"]
super().process()
def process_ifc(self, file, path):
file.write(path)
def register():
bpy.utils.register_class(SvIfcWriteFile)
def unregister():
bpy.utils.unregister_class(SvIfcWriteFile)