mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-31 17:06:29 +00:00
typing
This commit is contained in:
@@ -19,11 +19,12 @@
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.aggregate
|
||||
from typing import Union
|
||||
|
||||
|
||||
def assign_work_plan(
|
||||
file: ifcopenshell.file, work_schedule: ifcopenshell.entity_instance, work_plan: ifcopenshell.entity_instance
|
||||
) -> ifcopenshell.entity_instance:
|
||||
) -> Union[ifcopenshell.entity_instance, None]:
|
||||
"""Assigns a work schedule to a work plan
|
||||
|
||||
Typically, work schedules would be assigned to a work plan at creation.
|
||||
@@ -31,11 +32,8 @@ def assign_work_plan(
|
||||
|
||||
:param work_schedule: The IfcWorkSchedule that will be assigned to the
|
||||
work plan.
|
||||
:type work_schedule: ifcopenshell.entity_instance
|
||||
:param work_plan: The IfcWorkPlan for the schedule to be assigned to.
|
||||
:type work_plan: ifcopenshell.entity_instance
|
||||
:return: The IfcRelAggregates relationship
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
Example:
|
||||
|
||||
@@ -50,20 +48,16 @@ def assign_work_plan(
|
||||
# ... you can assign the work plan afterwards.
|
||||
ifcopenshell.api.sequence.assign_work_plan(work_schedule=schedule, work_plan=work_plan)
|
||||
"""
|
||||
settings = {"work_schedule": work_schedule, "work_plan": work_plan}
|
||||
|
||||
# TODO: this is an ambiguity by buildingSMART
|
||||
# See https://forums.buildingsmart.org/t/is-the-ifcworkschedule-project-declaration-mutually-exclusive-to-aggregation-within-a-relating-ifcworkplan/3510
|
||||
ifcopenshell.api.project.unassign_declaration(
|
||||
file,
|
||||
definitions=[settings["work_schedule"]],
|
||||
definitions=[work_schedule],
|
||||
relating_context=file.by_type("IfcContext")[0],
|
||||
)
|
||||
rel_aggregates = ifcopenshell.api.aggregate.assign_object(
|
||||
file,
|
||||
**{
|
||||
"products": [settings["work_schedule"]],
|
||||
"relating_object": settings["work_plan"],
|
||||
}
|
||||
products=[work_schedule],
|
||||
relating_object=work_plan,
|
||||
)
|
||||
return rel_aggregates
|
||||
|
||||
Reference in New Issue
Block a user