This commit is contained in:
Andrej730
2024-05-13 12:27:53 +05:00
parent c3bfd7354f
commit ebd03e9290
56 changed files with 244 additions and 127 deletions
@@ -21,7 +21,7 @@ import ifcopenshell.util.schema
import ifcopenshell.util.date
def add_library(file, name=None) -> None:
def add_library(file: ifcopenshell.entity_instance, name: str) -> ifcopenshell.entity_instance:
"""Adds a new library to the project
A library is an external data source that is related to the project. It
@@ -60,6 +60,4 @@ def add_library(file, name=None) -> None:
ifcopenshell.api.run("library.add_library", model, name="Brickschema")
"""
settings = {"name": name}
return file.create_entity("IfcLibraryInformation", Name=settings["name"])
return file.create_entity("IfcLibraryInformation", Name=name)
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_library(file, library=None, attributes=None) -> None:
def edit_library(file: ifcopenshell.file, library: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcLibraryInformation
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_library(file, library=None, attributes=None) -> None:
:param library: The IfcLibraryInformation entity you want to edit
:type library: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -39,7 +41,7 @@ def edit_library(file, library=None, attributes=None) -> None:
attributes={"Description": "A Brickschema TTL including only mechanical distribution systems."})
"""
settings = {"library": library, "attributes": attributes or {}}
settings = {"library": library, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["library"], name, value)
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_reference(file, reference=None, attributes=None) -> None:
def edit_reference(
file: ifcopenshell.file, reference: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcLibraryReference
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_reference(file, reference=None, attributes=None) -> None:
:param reference: The IfcLibraryReference entity you want to edit
:type reference: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -40,7 +44,7 @@ def edit_reference(file, reference=None, attributes=None) -> None:
ifcopenshell.api.run("library.edit_reference", model,
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
"""
settings = {"reference": reference, "attributes": attributes or {}}
settings = {"reference": reference, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["reference"], name, value)
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
def remove_library(file, library=None) -> None:
def remove_library(file: ifcopenshell.file, library: ifcopenshell.entity_instance) -> None:
"""Removes a library
All references along with their relationships will also be removed. Any