mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
Process derived attributes that are not redeclared (C++ has no knowledge of them)
This commit is contained in:
@@ -99,9 +99,7 @@ class entity_instance_mixin:
|
|||||||
"""
|
"""
|
||||||
INVALID, FORWARD, INVERSE, DERIVED = range(4)
|
INVALID, FORWARD, INVERSE, DERIVED = range(4)
|
||||||
attr_cat = self.get_attribute_category(name)
|
attr_cat = self.get_attribute_category(name)
|
||||||
if attr_cat == INVALID:
|
if attr_cat == FORWARD:
|
||||||
raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name))
|
|
||||||
elif attr_cat == FORWARD:
|
|
||||||
idx = self.get_argument_index(name)
|
idx = self.get_argument_index(name)
|
||||||
return self.get_argument(idx)
|
return self.get_argument(idx)
|
||||||
elif attr_cat == INVERSE:
|
elif attr_cat == INVERSE:
|
||||||
@@ -117,7 +115,7 @@ class entity_instance_mixin:
|
|||||||
else:
|
else:
|
||||||
vs = None
|
vs = None
|
||||||
return vs
|
return vs
|
||||||
elif attr_cat == DERIVED:
|
else:
|
||||||
schema_name = self.is_a(True).split(".")[0]
|
schema_name = self.is_a(True).split(".")[0]
|
||||||
try:
|
try:
|
||||||
rules = importlib.import_module(f"ifcopenshell.express.rules.{schema_name}")
|
rules = importlib.import_module(f"ifcopenshell.express.rules.{schema_name}")
|
||||||
@@ -146,9 +144,10 @@ class entity_instance_mixin:
|
|||||||
decl = decl.supertype()
|
decl = decl.supertype()
|
||||||
|
|
||||||
for sty in yield_supertypes():
|
for sty in yield_supertypes():
|
||||||
fn = getattr(rules, f"calc_{sty}_{name}", None)
|
if fn := getattr(rules, f"calc_{sty}_{name}", None):
|
||||||
if fn:
|
|
||||||
return fn(self)
|
return fn(self)
|
||||||
|
|
||||||
|
raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def walk(f: Callable[[Any], bool], g: Callable[[Any], Any], value: Any) -> Any:
|
def walk(f: Callable[[Any], bool], g: Callable[[Any], Any], value: Any) -> Any:
|
||||||
|
|||||||
Reference in New Issue
Block a user