mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
Generate functions for all API usecases for better static code features. See #2693.
This commit is contained in:
@@ -21,48 +21,45 @@ import ifcopenshell.util.schema
|
||||
import ifcopenshell.util.date
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, name=None):
|
||||
"""Adds a new library to the project
|
||||
def add_library(file, name=None) -> None:
|
||||
"""Adds a new library to the project
|
||||
|
||||
A library is an external data source that is related to the project. It
|
||||
may be a database, a spreadsheet, an API, or even a stack of papers in a
|
||||
filing cabinet. This allows IFC data to store relationships to these
|
||||
external data sources.
|
||||
A library is an external data source that is related to the project. It
|
||||
may be a database, a spreadsheet, an API, or even a stack of papers in a
|
||||
filing cabinet. This allows IFC data to store relationships to these
|
||||
external data sources.
|
||||
|
||||
For example, you may have a list of laser scans of a site stored in an
|
||||
online platform, which can be queried using an API. Or, you might have a
|
||||
database of live building sensor data. So long as there is a clear
|
||||
identifier you can use to link the two datasets together, you can create
|
||||
a relationship.
|
||||
For example, you may have a list of laser scans of a site stored in an
|
||||
online platform, which can be queried using an API. Or, you might have a
|
||||
database of live building sensor data. So long as there is a clear
|
||||
identifier you can use to link the two datasets together, you can create
|
||||
a relationship.
|
||||
|
||||
Note that IFC does not store any instructions on how to access the
|
||||
library. It does not specify whether a HTTP request or database
|
||||
connection needs to be made or what protocol the library operates with.
|
||||
Until this is fleshed out further, it is the users responsibility to
|
||||
name the libraries consistently and use appropriate identifiers. For
|
||||
example, if you are linking IFC data and Brickschema data, use a full
|
||||
URI for the identifier with no abbreviation (e.g.
|
||||
'http://example.org/digitaltwin#AHU01', not 'digitaltwin:AHU01').
|
||||
Note that IFC does not store any instructions on how to access the
|
||||
library. It does not specify whether a HTTP request or database
|
||||
connection needs to be made or what protocol the library operates with.
|
||||
Until this is fleshed out further, it is the users responsibility to
|
||||
name the libraries consistently and use appropriate identifiers. For
|
||||
example, if you are linking IFC data and Brickschema data, use a full
|
||||
URI for the identifier with no abbreviation (e.g.
|
||||
'http://example.org/digitaltwin#AHU01', not 'digitaltwin:AHU01').
|
||||
|
||||
A library will then contain a list of references within that library.
|
||||
These references will then be related to IFC elements. For example, a
|
||||
library will represent an external database, and a reference will point
|
||||
to a particular table and row within that database.
|
||||
A library will then contain a list of references within that library.
|
||||
These references will then be related to IFC elements. For example, a
|
||||
library will represent an external database, and a reference will point
|
||||
to a particular table and row within that database.
|
||||
|
||||
:param name: The name of the library
|
||||
:type name: str
|
||||
:return: The newly created IfcLibraryInformation
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
:param name: The name of the library
|
||||
:type name: str
|
||||
:return: The newly created IfcLibraryInformation
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
Example:
|
||||
Example:
|
||||
|
||||
.. code:: python
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"name": name}
|
||||
ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||
"""
|
||||
settings = {"name": name}
|
||||
|
||||
def execute(self):
|
||||
return self.file.create_entity("IfcLibraryInformation", Name=self.settings["name"])
|
||||
return file.create_entity("IfcLibraryInformation", Name=settings["name"])
|
||||
|
||||
Reference in New Issue
Block a user