mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -52,19 +52,19 @@ def cascade_schedule(file: ifcopenshell.file, task: ifcopenshell.entity_instance
|
||||
# Define a convenience function to add a task chained to a predecessor
|
||||
def add_task(model, name, predecessor, work_schedule):
|
||||
# Add a construction task
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=work_schedule, name=name, predefined_type="CONSTRUCTION")
|
||||
|
||||
# Give it a time
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", model, task=task)
|
||||
task_time = ifcopenshell.api.sequence.add_task_time(model, task=task)
|
||||
|
||||
# Arbitrarily set the task's scheduled time duration to be 1 week
|
||||
ifcopenshell.api.run("sequence.edit_task_time", model, task_time=task_time,
|
||||
ifcopenshell.api.sequence.edit_task_time(model, task_time=task_time,
|
||||
attributes={"ScheduleStart": datetime.date(2000, 1, 1), "ScheduleDuration": "P1W"})
|
||||
|
||||
# If a predecessor exists, create a finish to start relationship
|
||||
if predecessor:
|
||||
ifcopenshell.api.run("sequence.assign_sequence", model,
|
||||
ifcopenshell.api.sequence.assign_sequence(model,
|
||||
relating_process=predecessor, related_process=task)
|
||||
|
||||
return task
|
||||
@@ -73,7 +73,7 @@ def cascade_schedule(file: ifcopenshell.file, task: ifcopenshell.entity_instance
|
||||
model = ifcopenshell.open("/path/to/existing/model.ifc")
|
||||
|
||||
# Create a new construction schedule
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction")
|
||||
|
||||
# Let's imagine a starting task for site establishment.
|
||||
task = add_task(model, "Site establishment", None, schedule)
|
||||
@@ -90,16 +90,16 @@ def cascade_schedule(file: ifcopenshell.file, task: ifcopenshell.entity_instance
|
||||
|
||||
# Assign all the products in that storey to the task as construction outputs.
|
||||
for product in get_decomposition(storey):
|
||||
ifcopenshell.api.run("sequence.assign_product", model, relating_product=product, related_object=task)
|
||||
ifcopenshell.api.sequence.assign_product(model, relating_product=product, related_object=task)
|
||||
|
||||
# Ask the computer to calculate all the dates for us from the start task.
|
||||
# For example, if the first task started on the 1st of January and took a
|
||||
# week, the next task will start on the 8th of January. This saves us
|
||||
# manually doing date calculations.
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", model, task=start_task)
|
||||
ifcopenshell.api.sequence.cascade_schedule(model, task=start_task)
|
||||
|
||||
# Calculate the critical path and floats.
|
||||
ifcopenshell.api.run("sequence.recalculate_schedule", model, work_schedule=schedule)
|
||||
ifcopenshell.api.sequence.recalculate_schedule(model, work_schedule=schedule)
|
||||
"""
|
||||
usecase = Usecase()
|
||||
usecase.file = file
|
||||
|
||||
Reference in New Issue
Block a user