mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
typing
This commit is contained in:
@@ -15,10 +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
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, identification="APTR", name="Aperture Science"):
|
||||
def __init__(self, file: ifcopenshell.file, identification: str = "APTR", name: str = "Aperture Science"):
|
||||
"""Adds a new organisation
|
||||
|
||||
Organisations are the main way to identify manufacturers, suppliers, and
|
||||
@@ -45,7 +46,7 @@ class Usecase:
|
||||
self.file = file
|
||||
self.settings = {"identification": identification, "name": name}
|
||||
|
||||
def execute(self):
|
||||
def execute(self) -> ifcopenshell.entity_instance:
|
||||
data = {"Name": self.settings["name"]}
|
||||
if self.file.schema == "IFC2X3":
|
||||
data["Id"] = self.settings["identification"]
|
||||
|
||||
@@ -15,10 +15,17 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, identification="HSeldon", family_name="Seldon", given_name="Hari"):
|
||||
def __init__(
|
||||
self,
|
||||
file: ifcopenshell.entity_instance,
|
||||
identification: str = "HSeldon",
|
||||
family_name: str = "Seldon",
|
||||
given_name: str = "Hari",
|
||||
):
|
||||
"""Adds a new person
|
||||
|
||||
Persons are used to identify a legal or liable representative of an
|
||||
@@ -48,7 +55,7 @@ class Usecase:
|
||||
"given_name": given_name,
|
||||
}
|
||||
|
||||
def execute(self):
|
||||
def execute(self) ->ifcopenshell.entity_instance:
|
||||
data = {"FamilyName": self.settings["family_name"], "GivenName": self.settings["given_name"]}
|
||||
if self.file.schema == "IFC2X3":
|
||||
data["Id"] = self.settings["identification"]
|
||||
|
||||
@@ -15,10 +15,16 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, person=None, organisation=None):
|
||||
def __init__(
|
||||
self,
|
||||
file: ifcopenshell.entity_instance,
|
||||
person: ifcopenshell.entity_instance,
|
||||
organisation: ifcopenshell.entity_instance,
|
||||
):
|
||||
"""Adds a paired person and organisation
|
||||
|
||||
A person and an organisation may be paired to create a representative
|
||||
@@ -47,5 +53,5 @@ class Usecase:
|
||||
self.file = file
|
||||
self.settings = {"person": person, "organisation": organisation}
|
||||
|
||||
def execute(self):
|
||||
def execute(self) -> ifcopenshell.entity_instance:
|
||||
return self.file.createIfcPersonAndOrganization(self.settings["person"], self.settings["organisation"])
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
import time
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.owner.settings
|
||||
from typing import Union
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file):
|
||||
def __init__(self, file: ifcopenshell.entity_instance):
|
||||
"""Creates a new owner history indicating an element was added
|
||||
|
||||
Any object in IFC with a unique ID and name (such as physical products,
|
||||
@@ -59,8 +60,9 @@ class Usecase:
|
||||
are writing your own advanced scripts and want to take advantage of the
|
||||
easier ownership tracking.
|
||||
|
||||
:return: The newly created IfcOwnerHistory element.
|
||||
:rtype: ifcopenshell.entity_instance.entity_instance
|
||||
:return: The newly created IfcOwnerHistory element or `None` if it's
|
||||
not IFC2X3 and user or application is not found in the current project.
|
||||
:rtype: Union[ifcopenshell.entity_instance.entity_instance, None]
|
||||
|
||||
Example:
|
||||
|
||||
@@ -99,7 +101,7 @@ class Usecase:
|
||||
self.file = file
|
||||
self.settings = {}
|
||||
|
||||
def execute(self):
|
||||
def execute(self) -> Union[ifcopenshell.entity_instance, None]:
|
||||
user = ifcopenshell.api.owner.settings.get_user(self.file)
|
||||
if self.file.schema != "IFC2X3" and not user:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user