mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-20 04:04:00 +00:00
Implement read, create, and write for IfcSverchok
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcsverchok.helper
|
||||
from bpy.props import StringProperty
|
||||
from sverchok.node_tree import SverchCustomTreeNode
|
||||
from sverchok.data_structure import updateNode
|
||||
|
||||
|
||||
class SvCreateIfc(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
|
||||
bl_idname = 'SvCreateIfc'
|
||||
bl_label = 'Create IFC'
|
||||
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')
|
||||
|
||||
def process(self):
|
||||
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]]])
|
||||
|
||||
def register():
|
||||
bpy.utils.register_class(SvCreateIfc)
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(SvCreateIfc)
|
||||
@@ -0,0 +1,31 @@
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcsverchok.helper
|
||||
from bpy.props import StringProperty
|
||||
from sverchok.node_tree import SverchCustomTreeNode
|
||||
from sverchok.data_structure import updateNode
|
||||
|
||||
|
||||
class SvReadIfc(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
|
||||
bl_idname = 'SvReadIfc'
|
||||
bl_label = 'Read IFC'
|
||||
path: StringProperty(name='path', update=updateNode)
|
||||
|
||||
def sv_init(self, context):
|
||||
self.inputs.new('SvStringsSocket', 'path').prop_name = 'path'
|
||||
self.outputs.new('SvVerticesSocket', 'file')
|
||||
|
||||
def process(self):
|
||||
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]]])
|
||||
|
||||
def register():
|
||||
bpy.utils.register_class(SvReadIfc)
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(SvReadIfc)
|
||||
@@ -0,0 +1,30 @@
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcsverchok.helper
|
||||
from bpy.props import StringProperty
|
||||
from sverchok.node_tree import SverchCustomTreeNode
|
||||
from sverchok.data_structure import updateNode
|
||||
|
||||
|
||||
class SvWriteIfc(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore):
|
||||
bl_idname = 'SvWriteIfc'
|
||||
bl_label = 'Write IFC'
|
||||
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'
|
||||
|
||||
def process(self):
|
||||
self.sv_input_names = ['file', 'path']
|
||||
super().process()
|
||||
|
||||
def process_ifc(self, file, path):
|
||||
file.write(path)
|
||||
|
||||
def register():
|
||||
bpy.utils.register_class(SvWriteIfc)
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(SvWriteIfc)
|
||||
Reference in New Issue
Block a user