mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
Return support for creating uninitialized files from Python
Created a new method to avoid complicating `ifcopenshell.file` ctor signature.
This commit is contained in:
@@ -237,7 +237,7 @@ def open(
|
|||||||
if readonly: # Temporary conditional see #7131. Remove once newer builds don't segfault on Linux.
|
if readonly: # Temporary conditional see #7131. Remove once newer builds don't segfault on Linux.
|
||||||
f = ifcopenshell_wrapper.open(str(path.absolute()), readonly, *optional_logger_args(logger))
|
f = ifcopenshell_wrapper.open(str(path.absolute()), readonly, *optional_logger_args(logger))
|
||||||
elif bypass_types:
|
elif bypass_types:
|
||||||
f = ifcopenshell_wrapper.file(ifcopenshell_wrapper.uninitialized_tag(), *optional_logger_args(logger))
|
f = ifcopenshell_wrapper.file.create_uninitialized(*optional_logger_args(logger))
|
||||||
for ty in bypass_types:
|
for ty in bypass_types:
|
||||||
f.bypass_type(ty)
|
f.bypass_type(ty)
|
||||||
if mmap:
|
if mmap:
|
||||||
|
|||||||
@@ -845,6 +845,27 @@ class file(file_mixin):
|
|||||||
schema_identifier: str | None = None,
|
schema_identifier: str | None = None,
|
||||||
schema_version: tuple[int, int, int, int] | None = None,
|
schema_version: tuple[int, int, int, int] | None = None,
|
||||||
): ...
|
): ...
|
||||||
|
@staticmethod
|
||||||
|
def create_uninitialized(logger: logger | None = None) -> file:
|
||||||
|
"""Construct a file with no schema/data yet, to be populated by a later call to ``initialize()``.
|
||||||
|
|
||||||
|
When file is uninitialized, the only two available methods during
|
||||||
|
this state are ``bypass_type()`` and ``initialize()``.
|
||||||
|
"""
|
||||||
|
...
|
||||||
|
|
||||||
|
def bypass_type(self, type_name: str) -> None:
|
||||||
|
"""Skip loading instances of ``type_name``."""
|
||||||
|
...
|
||||||
|
# NOTE: inaccurate `*args` - not all args are `str`.
|
||||||
|
def initialize(self, *args: str) -> bool:
|
||||||
|
"""Parse a file on a ``create_uninitialized()`` instance.
|
||||||
|
|
||||||
|
:param args: ``args[0]`` is a string path to the IFC file.
|
||||||
|
:return: Whether the file was read and parsed successfully. On failure, check ``good()`` for the specific reason.
|
||||||
|
"""
|
||||||
|
...
|
||||||
|
|
||||||
def _add(self, entity: entity_instance, id: int = -1) -> entity_instance: ...
|
def _add(self, entity: entity_instance, id: int = -1) -> entity_instance: ...
|
||||||
def add_type_ref(self, new_entity): ...
|
def add_type_ref(self, new_entity): ...
|
||||||
def batch(self) -> None:
|
def batch(self) -> None:
|
||||||
@@ -873,7 +894,6 @@ class file(file_mixin):
|
|||||||
def by_id(self, instance_id: int) -> entity_instance: ...
|
def by_id(self, instance_id: int) -> entity_instance: ...
|
||||||
def _by_type(self, *args: declaration | str) -> tuple[entity_instance, ...]: ...
|
def _by_type(self, *args: declaration | str) -> tuple[entity_instance, ...]: ...
|
||||||
def _by_type_excl_subtypes(self, *args: declaration | str) -> tuple[entity_instance, ...]: ...
|
def _by_type_excl_subtypes(self, *args: declaration | str) -> tuple[entity_instance, ...]: ...
|
||||||
def bypass_type(self, type_name: str) -> None: ...
|
|
||||||
def create(self, *args) -> entity_instance: ...
|
def create(self, *args) -> entity_instance: ...
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_timestamp() -> str: ...
|
def create_timestamp() -> str: ...
|
||||||
@@ -910,7 +930,6 @@ class file(file_mixin):
|
|||||||
@property
|
@property
|
||||||
def header(self) -> spf_header: ...
|
def header(self) -> spf_header: ...
|
||||||
def ifcroot_type(self) -> entity: ...
|
def ifcroot_type(self) -> entity: ...
|
||||||
def initialize(self, *args): ...
|
|
||||||
def key_value_store_iter(self, prefix): ...
|
def key_value_store_iter(self, prefix): ...
|
||||||
def key_value_store_query(self, key): ...
|
def key_value_store_query(self, key): ...
|
||||||
def recalculate_id_counter(self): ...
|
def recalculate_id_counter(self): ...
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ private:
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
%newobject ifcopenshell::file::key_value_store_iter;
|
%newobject ifcopenshell::file::key_value_store_iter;
|
||||||
|
%newobject ifcopenshell::file::create_uninitialized;
|
||||||
|
|
||||||
%extend ifcopenshell::file {
|
%extend ifcopenshell::file {
|
||||||
/*
|
/*
|
||||||
@@ -274,6 +275,10 @@ private:
|
|||||||
return new ifcopenshell::file(ifcopenshell::schema_by_name(schema));
|
return new ifcopenshell::file(ifcopenshell::schema_by_name(schema));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ifcopenshell::file* create_uninitialized(logger* logger=nullptr) {
|
||||||
|
return new ifcopenshell::file(ifcopenshell::uninitialized_tag{}, logger_or_root(logger));
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<express::Base> _get_inverse(const express::Base& e) {
|
std::vector<express::Base> _get_inverse(const express::Base& e) {
|
||||||
if (auto e_ = e.as<express::Entity>()) {
|
if (auto e_ = e.as<express::Entity>()) {
|
||||||
return cast_vector<express::Base>($self->get_inverse(e_.id(), 0, -1));
|
return cast_vector<express::Base>($self->get_inverse(e_.id(), 0, -1));
|
||||||
|
|||||||
Reference in New Issue
Block a user