mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
ifcopenshell.util - make ifc_file argument optional if it can be deduced from ifc element
This commit is contained in:
@@ -140,7 +140,7 @@ def get_subtypes(
|
||||
|
||||
|
||||
def reassign_class(
|
||||
ifc_file: ifcopenshell.file, element: ifcopenshell.entity_instance, new_class: str
|
||||
ifc_file: Union[ifcopenshell.file, None], element: ifcopenshell.entity_instance, new_class: str
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""
|
||||
Attempts to change the class (entity name) of `element` to `new_class` by
|
||||
@@ -156,6 +156,9 @@ def reassign_class(
|
||||
It's unlikely that this affects real-world usage of this function.
|
||||
"""
|
||||
|
||||
if not ifc_file:
|
||||
ifc_file = element.file
|
||||
|
||||
schema: ifcopenshell_wrapper.schema_definition = ifcopenshell_wrapper.schema_by_name(ifc_file.schema)
|
||||
try:
|
||||
declaration = schema.declaration_by_name(new_class)
|
||||
|
||||
Reference in New Issue
Block a user