diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index 827c6c3324..06843bc90a 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -52,7 +52,7 @@ except Exception as e: from . import guid from .file import file -from .entity_instance import entity_instance +from .entity_instance import entity_instance, register_schema_attributes READ_ERROR = ifcopenshell_wrapper.file_open_status.READ_ERROR NO_HEADER = ifcopenshell_wrapper.file_open_status.NO_HEADER @@ -97,6 +97,7 @@ gcroot = [] def register_schema(schema): gcroot.append(schema) ifcopenshell_wrapper.register_schema(schema.schema) + register_schema_attributes(schema.schema) from .main import * diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index 796c72bec9..3d54ef70e8 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -51,11 +51,12 @@ def set_derived_atribute(*args): # mapping is built once during initialization of the # module. _method_dict = {} -for nm in ifcopenshell_wrapper.schema_names(): - schema = ifcopenshell_wrapper.schema_by_name(nm) + + +def register_schema_attributes(schema): for decl in schema.declarations(): if hasattr(decl, "argument_types"): - fq_name = ".".join((nm, decl.name())) + fq_name = ".".join((schema.name(), decl.name())) # get type strings as reported by IfcOpenShell C++ type_strs = decl.argument_types() @@ -81,6 +82,11 @@ for nm in ifcopenshell_wrapper.schema_names(): _method_dict[fq_name] = functions +for nm in ifcopenshell_wrapper.schema_names(): + schema = ifcopenshell_wrapper.schema_by_name(nm) + register_schema_attributes(schema) + + class entity_instance(object): """This is the base Python class for all IFC objects.