mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
typing
This commit is contained in:
@@ -16,9 +16,11 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
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
|
"""Creates a new reference to a document to assign to products
|
||||||
|
|
||||||
A document may be associated with physical products, tasks, cost items,
|
A document may be associated with physical products, tasks, cost items,
|
||||||
@@ -65,7 +67,7 @@ class Usecase:
|
|||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {"information": information}
|
self.settings = {"information": information}
|
||||||
|
|
||||||
def execute(self):
|
def execute(self) -> ifcopenshell.entity_instance:
|
||||||
if self.file.schema == "IFC2X3":
|
if self.file.schema == "IFC2X3":
|
||||||
reference = self.file.create_entity("IfcDocumentReference")
|
reference = self.file.create_entity("IfcDocumentReference")
|
||||||
if self.settings["information"]:
|
if self.settings["information"]:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import ifcopenshell.util.element
|
|||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, reference=None):
|
def __init__(self, file: ifcopenshell.file, reference: ifcopenshell.entity_instance):
|
||||||
"""Remove a document reference
|
"""Remove a document reference
|
||||||
|
|
||||||
All associations with objects are removed.
|
All associations with objects are removed.
|
||||||
@@ -42,7 +42,7 @@ class Usecase:
|
|||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {"reference": reference}
|
self.settings = {"reference": reference}
|
||||||
|
|
||||||
def execute(self):
|
def execute(self) -> None:
|
||||||
for rel in self.settings["reference"].DocumentRefForObjects or []:
|
for rel in self.settings["reference"].DocumentRefForObjects or []:
|
||||||
history = rel.OwnerHistory
|
history = rel.OwnerHistory
|
||||||
self.file.remove(rel)
|
self.file.remove(rel)
|
||||||
|
|||||||
@@ -16,9 +16,11 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
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
|
"""Adds a new reference to a library
|
||||||
|
|
||||||
A library represents an external data source, such as a database,
|
A library represents an external data source, such as a database,
|
||||||
@@ -54,7 +56,7 @@ class Usecase:
|
|||||||
"library": library,
|
"library": library,
|
||||||
}
|
}
|
||||||
|
|
||||||
def execute(self):
|
def execute(self) -> ifcopenshell.entity_instance:
|
||||||
if self.file.schema == "IFC2X3":
|
if self.file.schema == "IFC2X3":
|
||||||
reference = self.file.createIfcLibraryReference()
|
reference = self.file.createIfcLibraryReference()
|
||||||
references = list(self.settings["library"].LibraryReference or [])
|
references = list(self.settings["library"].LibraryReference or [])
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import ifcopenshell.util.element
|
|||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, reference=None):
|
def __init__(self, file: ifcopenshell.file, reference: ifcopenshell.entity_instance):
|
||||||
"""Removes a library reference
|
"""Removes a library reference
|
||||||
|
|
||||||
Any products which have relationships to this reference will not be
|
Any products which have relationships to this reference will not be
|
||||||
@@ -44,7 +44,7 @@ class Usecase:
|
|||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {"reference": reference}
|
self.settings = {"reference": reference}
|
||||||
|
|
||||||
def execute(self):
|
def execute(self) -> None:
|
||||||
for rel in self.settings["reference"].LibraryRefForObjects:
|
for rel in self.settings["reference"].LibraryRefForObjects:
|
||||||
history = rel.OwnerHistory
|
history = rel.OwnerHistory
|
||||||
self.file.remove(rel)
|
self.file.remove(rel)
|
||||||
|
|||||||
@@ -18,10 +18,17 @@
|
|||||||
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
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
|
"""Create a new rooted product
|
||||||
|
|
||||||
This is a critical function used to create almost any rooted product or
|
This is a critical function used to create almost any rooted product or
|
||||||
@@ -70,7 +77,7 @@ class Usecase:
|
|||||||
"name": name,
|
"name": name,
|
||||||
}
|
}
|
||||||
|
|
||||||
def execute(self):
|
def execute(self) -> ifcopenshell.entity_instance:
|
||||||
element = self.file.create_entity(
|
element = self.file.create_entity(
|
||||||
self.settings["ifc_class"],
|
self.settings["ifc_class"],
|
||||||
**{
|
**{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import ifcopenshell.util.element
|
|||||||
|
|
||||||
|
|
||||||
class Usecase:
|
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
|
"""Removes a product
|
||||||
|
|
||||||
This is effectively a smart delete function that not only removes a
|
This is effectively a smart delete function that not only removes a
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import ifcopenshell.api
|
|||||||
|
|
||||||
|
|
||||||
class Usecase:
|
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
|
"""Add a new distribution system
|
||||||
|
|
||||||
A distribution system is a group of distribution elements, like ducts,
|
A distribution system is a group of distribution elements, like ducts,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import ifcopenshell.util.element
|
|||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
file: ifcopenshell.entity_instance,
|
file: ifcopenshell.file,
|
||||||
products: list[ifcopenshell.entity_instance],
|
products: list[ifcopenshell.entity_instance],
|
||||||
system: ifcopenshell.entity_instance,
|
system: ifcopenshell.entity_instance,
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -20,10 +20,11 @@ import ifcopenshell
|
|||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.util.selector
|
import ifcopenshell.util.selector
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
from logging import Logger
|
||||||
|
|
||||||
|
|
||||||
class Patcher:
|
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 certain elements into a new model
|
||||||
|
|
||||||
Extract a subset of elements from an existing IFC data set and save it
|
Extract a subset of elements from an existing IFC data set and save it
|
||||||
|
|||||||
@@ -19,10 +19,11 @@
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
from logging import Logger
|
||||||
|
|
||||||
|
|
||||||
class Patcher:
|
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
|
"""Merge duplicate element types via the Tag or another attribute
|
||||||
|
|
||||||
Revit is notorious for creating many duplicate element types. Element
|
Revit is notorious for creating many duplicate element types. Element
|
||||||
@@ -78,7 +79,9 @@ class Patcher:
|
|||||||
else:
|
else:
|
||||||
keys[getattr(element_type, key)] = element_type
|
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
|
# This is basically a portion of the type.assign_type API which only
|
||||||
# affects the IfcRelDefinesByType relationship. To be conservative, we
|
# affects the IfcRelDefinesByType relationship. To be conservative, we
|
||||||
# don't use the API directly since that would do other things like
|
# don't use the API directly since that would do other things like
|
||||||
|
|||||||
Reference in New Issue
Block a user