mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Work on python wrapper
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user