mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 06:18:09 +00:00
typing
This commit is contained in:
@@ -53,7 +53,7 @@ def execute(args: ArgumentsDict) -> Union[ifcopenshell.file, str]:
|
||||
|
||||
:param args: A dictionary of arguments, corresponding to the parameters
|
||||
listed subsequent to this in this docstring.
|
||||
:type args: dict
|
||||
:type args: ArgumentsDict
|
||||
:param file: An IFC model to apply the patch recipe to.
|
||||
Required for most recipes except the ones that require `input`.
|
||||
:type file: ifcopenshell.file, optional
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.selector
|
||||
from typing import Union
|
||||
@@ -81,8 +82,8 @@ class Patcher:
|
||||
pass
|
||||
if element.is_a("IfcProject"):
|
||||
return self.new.add(element)
|
||||
return ifcopenshell.api.run(
|
||||
"project.append_asset", self.new, library=self.file, element=element, reuse_identities=self.reuse_identities
|
||||
return ifcopenshell.api.project.append_asset(
|
||||
self.new, library=self.file, element=element, reuse_identities=self.reuse_identities
|
||||
)
|
||||
|
||||
def add_spatial_structures(
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.type
|
||||
import ifcopenshell.util.element
|
||||
from logging import Logger
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Patcher:
|
||||
@@ -48,7 +50,6 @@ class Patcher:
|
||||
:param attribute: The name of the attribute to merge element types based
|
||||
on. Typically this will be "Tag" as it stores the unique ID from the
|
||||
proprietary BIM software.
|
||||
:type attribute: str
|
||||
|
||||
Example:
|
||||
|
||||
@@ -66,7 +67,7 @@ class Patcher:
|
||||
|
||||
def patch(self):
|
||||
key = self.attribute
|
||||
keys = {}
|
||||
keys: dict[Any, ifcopenshell.entity_instance] = {}
|
||||
for element_type in self.file.by_type("IfcTypeObject"):
|
||||
original_type = keys.get(getattr(element_type, key), None)
|
||||
if original_type:
|
||||
@@ -86,8 +87,7 @@ class Patcher:
|
||||
# since that would do other things like
|
||||
# map type representations or recalculate material set usages which is
|
||||
# risky when we're patching an existing dataset.
|
||||
ifcopenshell.api.run(
|
||||
"type.assign_type",
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file,
|
||||
relating_type=relating_type,
|
||||
related_objects=related_objects,
|
||||
|
||||
Reference in New Issue
Block a user