This commit is contained in:
Andrej730
2024-04-12 10:42:15 +05:00
parent e56aa45a82
commit 59b496d4b5
10 changed files with 31 additions and 16 deletions
@@ -16,9 +16,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, information=None):
def __init__(self, file: ifcopenshell.file, information: ifcopenshell.entity_instance):
"""Creates a new reference to a document to assign to products
A document may be associated with physical products, tasks, cost items,
@@ -65,7 +67,7 @@ class Usecase:
self.file = file
self.settings = {"information": information}
def execute(self):
def execute(self) -> ifcopenshell.entity_instance:
if self.file.schema == "IFC2X3":
reference = self.file.create_entity("IfcDocumentReference")
if self.settings["information"]:
@@ -21,7 +21,7 @@ import ifcopenshell.util.element
class Usecase:
def __init__(self, file, reference=None):
def __init__(self, file: ifcopenshell.file, reference: ifcopenshell.entity_instance):
"""Remove a document reference
All associations with objects are removed.
@@ -42,7 +42,7 @@ class Usecase:
self.file = file
self.settings = {"reference": reference}
def execute(self):
def execute(self) -> None:
for rel in self.settings["reference"].DocumentRefForObjects or []:
history = rel.OwnerHistory
self.file.remove(rel)
@@ -16,9 +16,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, library=None):
def __init__(self, file: ifcopenshell.file, library: ifcopenshell.entity_instance):
"""Adds a new reference to a library
A library represents an external data source, such as a database,
@@ -54,7 +56,7 @@ class Usecase:
"library": library,
}
def execute(self):
def execute(self) -> ifcopenshell.entity_instance:
if self.file.schema == "IFC2X3":
reference = self.file.createIfcLibraryReference()
references = list(self.settings["library"].LibraryReference or [])
@@ -21,7 +21,7 @@ import ifcopenshell.util.element
class Usecase:
def __init__(self, file, reference=None):
def __init__(self, file: ifcopenshell.file, reference: ifcopenshell.entity_instance):
"""Removes a library reference
Any products which have relationships to this reference will not be
@@ -44,7 +44,7 @@ class Usecase:
self.file = file
self.settings = {"reference": reference}
def execute(self):
def execute(self) -> None:
for rel in self.settings["reference"].LibraryRefForObjects:
history = rel.OwnerHistory
self.file.remove(rel)
@@ -18,10 +18,17 @@
import ifcopenshell
import ifcopenshell.api
from typing import Optional
class Usecase:
def __init__(self, file, ifc_class="IfcBuildingElementProxy", predefined_type=None, name=None):
def __init__(
self,
file: ifcopenshell.file,
ifc_class: str = "IfcBuildingElementProxy",
predefined_type: Optional[str] = None,
name: Optional[str] = None,
):
"""Create a new rooted product
This is a critical function used to create almost any rooted product or
@@ -70,7 +77,7 @@ class Usecase:
"name": name,
}
def execute(self):
def execute(self) -> ifcopenshell.entity_instance:
element = self.file.create_entity(
self.settings["ifc_class"],
**{
@@ -21,7 +21,7 @@ import ifcopenshell.util.element
class Usecase:
def __init__(self, file: ifcopenshell.entity_instance, product: ifcopenshell.entity_instance):
def __init__(self, file: ifcopenshell.file, product: ifcopenshell.entity_instance):
"""Removes a product
This is effectively a smart delete function that not only removes a
@@ -21,7 +21,7 @@ import ifcopenshell.api
class Usecase:
def __init__(self, file: ifcopenshell.entity_instance, ifc_class: str = "IfcDistributionSystem"):
def __init__(self, file: ifcopenshell.file, ifc_class: str = "IfcDistributionSystem"):
"""Add a new distribution system
A distribution system is a group of distribution elements, like ducts,
@@ -24,7 +24,7 @@ import ifcopenshell.util.element
class Usecase:
def __init__(
self,
file: ifcopenshell.entity_instance,
file: ifcopenshell.file,
products: list[ifcopenshell.entity_instance],
system: ifcopenshell.entity_instance,
):
@@ -20,10 +20,11 @@ import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.selector
from typing import Union
from logging import Logger
class Patcher:
def __init__(self, src, file, logger, query: str = "IfcWall"):
def __init__(self, src: str, file: ifcopenshell.file, logger: Logger, query: str = "IfcWall"):
"""Extract certain elements into a new model
Extract a subset of elements from an existing IFC data set and save it
@@ -19,10 +19,11 @@
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.element
from logging import Logger
class Patcher:
def __init__(self, src, file, logger, attribute="Tag"):
def __init__(self, src: str, file: ifcopenshell.file, logger: Logger, attribute: str = "Tag"):
"""Merge duplicate element types via the Tag or another attribute
Revit is notorious for creating many duplicate element types. Element
@@ -78,7 +79,9 @@ class Patcher:
else:
keys[getattr(element_type, key)] = element_type
def assign_type(self, related_object, relating_type):
def assign_type(
self, related_object: ifcopenshell.entity_instance, relating_type: ifcopenshell.entity_instance
) -> None:
# This is basically a portion of the type.assign_type API which only
# affects the IfcRelDefinesByType relationship. To be conservative, we
# don't use the API directly since that would do other things like