Work on python wrapper

This commit is contained in:
Thomas Krijnen
2017-12-31 12:20:13 +01:00
parent 05e6f56911
commit e2f79ec1ba
12 changed files with 94 additions and 72 deletions
@@ -59,8 +59,8 @@ from .file import file
from .entity_instance import entity_instance
def open(fn=None):
return file(ifcopenshell_wrapper.open(os.path.abspath(fn))) if fn else file()
def open(fn):
return file(ifcopenshell_wrapper.open(os.path.abspath(fn)))
def create_entity(type, *args, **kwargs):
@@ -51,8 +51,8 @@ class entity_instance(object):
>>> #423=IfcProductDefinitionShape($,$,(#409,#421))
"""
def __init__(self, e):
if isinstance(e, str):
e = ifcopenshell_wrapper.new_IfcBaseClass(e)
if isinstance(e, tuple):
e = ifcopenshell_wrapper.new_IfcBaseClass(*e)
super(entity_instance, self).__setattr__('wrapped_data', e)
def __getattr__(self, name):
+8 -3
View File
@@ -55,11 +55,16 @@ class file(object):
print(products[0] == ifc_file[122] == ifc_file['2XQ$n5SLP5MBLyL442paFx'])
>>> True
"""
def __init__(self, f=None):
self.wrapped_data = f or ifcopenshell_wrapper.file()
def __init__(self, f=None, schema=None):
if f is not None:
self.wrapped_data = f
else:
args = filter(None, [schema])
args = map(ifcopenshell_wrapper.schema_by_name, args)
self.wrapped_data = ifcopenshell_wrapper.file(*args)
def create_entity(self, type, *args, **kwargs):
e = entity_instance(type)
e = entity_instance((self.schema, type))
self.wrapped_data.add(e.wrapped_data)
e.wrapped_data.this.disown()
attrs = list(enumerate(args)) + \
@@ -24,6 +24,4 @@ from __future__ import print_function
from . import ifcopenshell_wrapper
version = ifcopenshell_wrapper.version()
schema_identifier = ifcopenshell_wrapper.schema_identifier()
get_supertype = ifcopenshell_wrapper.get_supertype
get_log = ifcopenshell_wrapper.get_log