mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
#1567 add instance after the values are set
This commit is contained in:
@@ -264,19 +264,44 @@ class file(object):
|
|||||||
eid = kwargs.pop("id", -1)
|
eid = kwargs.pop("id", -1)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
e = entity_instance((self.schema, type), self)
|
e = entity_instance((self.schema, type), self)
|
||||||
self.wrapped_data.add(e.wrapped_data, eid)
|
|
||||||
e.wrapped_data.this.disown()
|
# Create pairs of {attribute index, attribute value}.
|
||||||
|
# Keyword arguments are mapped to their corresponding
|
||||||
|
# numeric index with get_argument_index().
|
||||||
|
|
||||||
|
# @todo we should probably check that values for
|
||||||
|
# attributes are not passed as duplicates using
|
||||||
|
# both regular arguments and keyword arguments.
|
||||||
attrs = list(enumerate(args)) + [(e.wrapped_data.get_argument_index(name), arg) for name, arg in kwargs.items()]
|
attrs = list(enumerate(args)) + [(e.wrapped_data.get_argument_index(name), arg) for name, arg in kwargs.items()]
|
||||||
|
|
||||||
|
# Don't store these attributes as transactions
|
||||||
|
# as the creation it self is already stored with
|
||||||
|
# it's arguments
|
||||||
if attrs:
|
if attrs:
|
||||||
transaction = self.transaction
|
transaction = self.transaction
|
||||||
self.transaction = None
|
self.transaction = None
|
||||||
|
|
||||||
for idx, arg in attrs:
|
for idx, arg in attrs:
|
||||||
e[idx] = arg
|
e[idx] = arg
|
||||||
|
|
||||||
|
# Restore transaction status
|
||||||
if attrs:
|
if attrs:
|
||||||
self.transaction = transaction
|
self.transaction = transaction
|
||||||
|
|
||||||
if self.transaction:
|
if self.transaction:
|
||||||
self.transaction.store_create(e)
|
self.transaction.store_create(e)
|
||||||
|
|
||||||
|
# Once the values are populated add the instance
|
||||||
|
# to the file.
|
||||||
|
self.wrapped_data.add(e.wrapped_data, eid)
|
||||||
|
|
||||||
|
# The file container now handles the lifetime of
|
||||||
|
# this instance. Tell SWIG that it is no longer
|
||||||
|
# the owner.
|
||||||
|
e.wrapped_data.this.disown()
|
||||||
|
|
||||||
return e
|
return e
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
|
|||||||
Reference in New Issue
Block a user