mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.nest
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell
|
||||
import ifcopenshell.guid
|
||||
from typing import Optional
|
||||
@@ -91,50 +93,50 @@ def add_task(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Add a root task to represent the design milestones, and major
|
||||
# project phases.
|
||||
ifcopenshell.api.run("sequence.add_task", model,
|
||||
ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Milestones", identification="A")
|
||||
ifcopenshell.api.run("sequence.add_task", model,
|
||||
ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Design", identification="B")
|
||||
construction = ifcopenshell.api.run("sequence.add_task", model,
|
||||
construction = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
|
||||
# Let's start creating our work breakdown structure.
|
||||
ifcopenshell.api.run("sequence.add_task", model,
|
||||
ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Early Works", identification="C1")
|
||||
ifcopenshell.api.run("sequence.add_task", model,
|
||||
ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Substructure", identification="C2")
|
||||
superstructure = ifcopenshell.api.run("sequence.add_task", model,
|
||||
superstructure = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Superstructure", identification="C3")
|
||||
|
||||
# Notice how the leaf task is the actual activity
|
||||
ifcopenshell.api.run("sequence.add_task", model,
|
||||
ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=superstructure, name="Ground Floor FRP", identification="C3.1")
|
||||
|
||||
# Let's imagine we are digitising an operations and maintenance
|
||||
# manual for the mechanical discipline.
|
||||
maintenance = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Mechanical Maintenance")
|
||||
maintenance = ifcopenshell.api.sequence.add_work_schedule(model, name="Mechanical Maintenance")
|
||||
|
||||
# Imagine we have to clean the condenser coils for a chiller every
|
||||
# month. Like the schedule above, to keep things simple we won't
|
||||
# show scheduling times and calendars. This root task represents the
|
||||
# overall maintenance task.
|
||||
cleaning = ifcopenshell.api.run("sequence.add_task", model,
|
||||
cleaning = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=maintenance, name="Condenser coil cleaning")
|
||||
|
||||
# These subtasks represent the punch list of maintenance tasks.
|
||||
ifcopenshell.api.run("sequence.add_task", model, parent_task=cleaning, identification="1",
|
||||
ifcopenshell.api.sequence.add_task(model, parent_task=cleaning, identification="1",
|
||||
description="Prior to work, wear safety shoes, gloves, and goggles.")
|
||||
ifcopenshell.api.run("sequence.add_task", model, parent_task=cleaning, identification="2",
|
||||
ifcopenshell.api.sequence.add_task(model, parent_task=cleaning, identification="2",
|
||||
description="Prepare jet pump, screwdriver, hose clamp, and control panel door key.")
|
||||
ifcopenshell.api.run("sequence.add_task", model, parent_task=cleaning, identification="3",
|
||||
ifcopenshell.api.sequence.add_task(model, parent_task=cleaning, identification="3",
|
||||
description="Switch OFF the chiller unit.")
|
||||
ifcopenshell.api.run("sequence.add_task", model, parent_task=cleaning, identification="3",
|
||||
ifcopenshell.api.sequence.add_task(model, parent_task=cleaning, identification="3",
|
||||
description="Open the isolator switch.")
|
||||
ifcopenshell.api.run("sequence.add_task", model, parent_task=cleaning, identification="3",
|
||||
ifcopenshell.api.sequence.add_task(model, parent_task=cleaning, identification="3",
|
||||
description="Setup the water pressure by tapping to a water supply and connecting to a ...")
|
||||
"""
|
||||
settings = {
|
||||
@@ -146,12 +148,8 @@ def add_task(
|
||||
"predefined_type": predefined_type,
|
||||
}
|
||||
|
||||
task = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
file,
|
||||
ifc_class="IfcTask",
|
||||
name=settings["name"],
|
||||
predefined_type=settings["predefined_type"],
|
||||
task = ifcopenshell.api.root.create_entity(
|
||||
file, ifc_class="IfcTask", name=settings["name"], predefined_type=settings["predefined_type"]
|
||||
)
|
||||
if settings["description"]:
|
||||
task.Description = settings["description"]
|
||||
@@ -163,14 +161,13 @@ def add_task(
|
||||
"IfcRelAssignsToControl",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": [task],
|
||||
"RelatingControl": settings["work_schedule"],
|
||||
}
|
||||
)
|
||||
elif settings["parent_task"]:
|
||||
rel = ifcopenshell.api.run(
|
||||
"nest.assign_object",
|
||||
rel = ifcopenshell.api.nest.assign_object(
|
||||
file,
|
||||
related_objects=[task],
|
||||
relating_object=settings["parent_task"],
|
||||
|
||||
@@ -40,25 +40,25 @@ def add_task_time(
|
||||
.. code:: python
|
||||
|
||||
# Let's imagine we are creating a construction schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Create a portion of a work breakdown structure.
|
||||
construction = ifcopenshell.api.run("sequence.add_task", model,
|
||||
construction = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
superstructure = ifcopenshell.api.run("sequence.add_task", model,
|
||||
superstructure = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Superstructure", identification="C3")
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=superstructure, name="Ground Floor FRP", identification="C3.1")
|
||||
|
||||
# Add time data. Note that time data is blank by default.
|
||||
time = ifcopenshell.api.run("sequence.add_task_time", model, task=task)
|
||||
time = ifcopenshell.api.sequence.add_task_time(model, task=task)
|
||||
|
||||
# Let's say our task starts on the first of January when everybody
|
||||
# is still drunk from the new years celebration, and lasts for 2
|
||||
# days. Note we don't need to specify the end date, as that is
|
||||
# derived from the start plus the duration. In this simple example,
|
||||
# no calendar has been specified, so we are working 24/7. Yikes!
|
||||
ifcopenshell.api.run("sequence.edit_task_time", model,
|
||||
ifcopenshell.api.sequence.edit_task_time(model,
|
||||
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
|
||||
"""
|
||||
settings = {"task": task, "is_recurring": is_recurring}
|
||||
|
||||
@@ -61,24 +61,24 @@ def add_time_period(
|
||||
.. code:: python
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model)
|
||||
|
||||
# Let's start defining the times that we work during the week.
|
||||
work_time = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
work_time = ifcopenshell.api.sequence.add_work_time(model,
|
||||
work_calendar=calendar, time_type="WorkingTimes")
|
||||
|
||||
# We create a weekly recurrence
|
||||
pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
|
||||
pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
|
||||
parent=work_time, recurrence_type="WEEKLY")
|
||||
|
||||
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday)
|
||||
ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
|
||||
ifcopenshell.api.sequence.edit_recurrence_pattern(model,
|
||||
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
|
||||
|
||||
# The morning work session, lunch, then the afternoon work session.
|
||||
ifcopenshell.api.run("sequence.add_time_period", model,
|
||||
ifcopenshell.api.sequence.add_time_period(model,
|
||||
recurrence_pattern=pattern, start_time="09:00", end_time="12:00")
|
||||
ifcopenshell.api.run("sequence.add_time_period", model,
|
||||
ifcopenshell.api.sequence.add_time_period(model,
|
||||
recurrence_pattern=pattern, start_time="13:00", end_time="17:00")
|
||||
"""
|
||||
settings = {
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.project
|
||||
|
||||
|
||||
def add_work_calendar(
|
||||
@@ -50,46 +51,44 @@ def add_work_calendar(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Add a root task to represent the construction tasks.
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model, name="5 Day Week")
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model, name="5 Day Week")
|
||||
|
||||
# Let's start defining the times that we work during the week.
|
||||
work_time = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
work_time = ifcopenshell.api.sequence.add_work_time(model,
|
||||
work_calendar=calendar, time_type="WorkingTimes")
|
||||
|
||||
# We create a weekly recurrence
|
||||
pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
|
||||
pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
|
||||
parent=work_time, recurrence_type="WEEKLY")
|
||||
|
||||
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday), 9am to 5pm
|
||||
ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
|
||||
ifcopenshell.api.sequence.edit_recurrence_pattern(model,
|
||||
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
|
||||
ifcopenshell.api.run("sequence.add_time_period", model,
|
||||
ifcopenshell.api.sequence.add_time_period(model,
|
||||
recurrence_pattern=pattern, start_time="09:00", end_time="17:00")
|
||||
|
||||
# We associate the calendar with the construction root task. All
|
||||
# subtasks underneath the construction work task will also inherit
|
||||
# this calendar by default (though you can override them).
|
||||
ifcopenshell.api.run("control.assign_control", model, relating_control=calendar, related_object=task)
|
||||
ifcopenshell.api.control.assign_control(model, relating_control=calendar, related_object=task)
|
||||
"""
|
||||
settings = {"name": name, "predefined_type": predefined_type}
|
||||
|
||||
work_calendar = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
work_calendar = ifcopenshell.api.root.create_entity(
|
||||
file,
|
||||
ifc_class="IfcWorkCalendar",
|
||||
predefined_type=settings["predefined_type"],
|
||||
name=settings["name"],
|
||||
)
|
||||
context = file.by_type("IfcContext")[0]
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration",
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
file,
|
||||
definitions=[work_calendar],
|
||||
relating_context=context,
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.owner.settings
|
||||
import ifcopenshell.util.date
|
||||
from datetime import datetime, time
|
||||
@@ -55,10 +56,10 @@ def add_work_plan(
|
||||
.. code:: python
|
||||
|
||||
# This will hold all our construction schedules
|
||||
work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
|
||||
work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
|
||||
|
||||
# This is one of our schedules in our work plan.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model,
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model,
|
||||
name="Construction Schedule A", work_plan=work_plan)
|
||||
"""
|
||||
settings = {
|
||||
@@ -67,8 +68,7 @@ def add_work_plan(
|
||||
"start_time": start_time or datetime.now(),
|
||||
}
|
||||
|
||||
work_plan = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
work_plan = ifcopenshell.api.root.create_entity(
|
||||
file,
|
||||
ifc_class="IfcWorkPlan",
|
||||
predefined_type=settings["predefined_type"],
|
||||
@@ -81,8 +81,7 @@ def add_work_plan(
|
||||
work_plan.StartTime = ifcopenshell.util.date.datetime2ifc(settings["start_time"], "IfcDateTime")
|
||||
|
||||
context = file.by_type("IfcContext")[0]
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration",
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
file,
|
||||
definitions=[work_plan],
|
||||
relating_context=context,
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.api.owner.settings
|
||||
import ifcopenshell.util.date
|
||||
from datetime import time
|
||||
@@ -60,19 +62,19 @@ def add_work_schedule(
|
||||
.. code:: python
|
||||
|
||||
# This will hold all our construction schedules
|
||||
work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
|
||||
work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
|
||||
|
||||
# Let's imagine this is one of our schedules in our work plan.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model,
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model,
|
||||
name="Construction Schedule A", work_plan=work_plan)
|
||||
|
||||
# Add a root task to represent the design milestones, and major
|
||||
# project phases.
|
||||
ifcopenshell.api.run("sequence.add_task", model,
|
||||
ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Milestones", identification="A")
|
||||
ifcopenshell.api.run("sequence.add_task", model,
|
||||
ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Design", identification="B")
|
||||
construction = ifcopenshell.api.run("sequence.add_task", model,
|
||||
construction = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
"""
|
||||
settings = {
|
||||
@@ -83,8 +85,7 @@ def add_work_schedule(
|
||||
"work_plan": work_plan,
|
||||
}
|
||||
|
||||
work_schedule = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
work_schedule = ifcopenshell.api.root.create_entity(
|
||||
file,
|
||||
ifc_class="IfcWorkSchedule",
|
||||
predefined_type=settings["predefined_type"],
|
||||
@@ -104,8 +105,7 @@ def add_work_schedule(
|
||||
if settings["object_type"]:
|
||||
work_schedule.ObjectType = settings["object_type"]
|
||||
if settings["work_plan"]:
|
||||
ifcopenshell.api.run(
|
||||
"aggregate.assign_object",
|
||||
ifcopenshell.api.aggregate.assign_object(
|
||||
file,
|
||||
**{
|
||||
"products": [work_schedule],
|
||||
@@ -116,8 +116,7 @@ def add_work_schedule(
|
||||
# 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
|
||||
context = file.by_type("IfcContext")[0]
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration",
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
file,
|
||||
definitions=[work_schedule],
|
||||
relating_context=context,
|
||||
|
||||
@@ -48,30 +48,30 @@ def add_work_time(
|
||||
.. code:: python
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model)
|
||||
|
||||
# Let's start defining the times that we work during the week.
|
||||
work_time = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
work_time = ifcopenshell.api.sequence.add_work_time(model,
|
||||
work_calendar=calendar, time_type="WorkingTimes")
|
||||
|
||||
# We create a weekly recurrence
|
||||
pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
|
||||
pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
|
||||
parent=work_time, recurrence_type="WEEKLY")
|
||||
|
||||
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday)
|
||||
ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
|
||||
ifcopenshell.api.sequence.edit_recurrence_pattern(model,
|
||||
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
|
||||
|
||||
# Let's set some holidays
|
||||
holidays = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
holidays = ifcopenshell.api.sequence.add_work_time(model,
|
||||
work_calendar=calendar, time_type="ExceptionTimes")
|
||||
|
||||
# We create a yearly recurrence
|
||||
pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
|
||||
pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
|
||||
parent=work_time, recurrence_type="YEARLY_BY_DAY_OF_MONTH")
|
||||
|
||||
# The holiday is every 1st of January
|
||||
ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
|
||||
ifcopenshell.api.sequence.edit_recurrence_pattern(model,
|
||||
recurrence_pattern=pattern, attributes={"DayComponent": [1], "MonthComponent": [1]})
|
||||
"""
|
||||
settings = {"work_calendar": work_calendar, "time_type": time_type}
|
||||
|
||||
@@ -52,37 +52,37 @@ def assign_lag_time(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's imagine a root construction task
|
||||
construction = ifcopenshell.api.run("sequence.add_task", model,
|
||||
construction = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
|
||||
# Let's imagine we're doing a typically formwork, reinforcement,
|
||||
# pour sequence. Let's start with the formwork. It'll take us 2
|
||||
# days.
|
||||
formwork = ifcopenshell.api.run("sequence.add_task", model,
|
||||
formwork = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Formwork", identification="C.1")
|
||||
time = ifcopenshell.api.run("sequence.add_task_time", model, task=formwork)
|
||||
ifcopenshell.api.run("sequence.edit_task_time", model,
|
||||
time = ifcopenshell.api.sequence.add_task_time(model, task=formwork)
|
||||
ifcopenshell.api.sequence.edit_task_time(model,
|
||||
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
|
||||
|
||||
# Now let's do the reinforcement. It'll take us another 2 days.
|
||||
reinforcement = ifcopenshell.api.run("sequence.add_task", model,
|
||||
reinforcement = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Reinforcement", identification="C.2")
|
||||
time = ifcopenshell.api.run("sequence.add_task_time", model, task=reinforcement)
|
||||
ifcopenshell.api.run("sequence.edit_task_time", model,
|
||||
time = ifcopenshell.api.sequence.add_task_time(model, task=reinforcement)
|
||||
ifcopenshell.api.sequence.edit_task_time(model,
|
||||
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
|
||||
|
||||
# Now let's say the formwork must finish before the reinforcement
|
||||
# can start. This is a typical finish to start relationship (FS).
|
||||
sequence = ifcopenshell.api.run("sequence.assign_sequence", model,
|
||||
sequence = ifcopenshell.api.sequence.assign_sequence(model,
|
||||
relating_process=formwork, related_process=reinforcement)
|
||||
|
||||
# Now typically there would be no lag time between formwork and
|
||||
# reinforcement, but let's pretend that we had to allow 1 day gap
|
||||
# for whatever reason.
|
||||
ifcopenshell.api.run("sequence.assign_lag_time", model, rel_sequence=sequence, lag_value="P1D")
|
||||
ifcopenshell.api.sequence.assign_lag_time(model, rel_sequence=sequence, lag_value="P1D")
|
||||
"""
|
||||
settings = {
|
||||
"rel_sequence": rel_sequence,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
@@ -78,18 +78,18 @@ def assign_process(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's create a construction task. Note that the predefined type is
|
||||
# important to distinguish types of tasks.
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Demolish existing", identification="A", predefined_type="DEMOLITION")
|
||||
|
||||
# Let's say we have a wall somewhere.
|
||||
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
|
||||
# Let's demolish that wall!
|
||||
ifcopenshell.api.run("sequence.assign_process", model, relating_process=task, related_object=wall)
|
||||
ifcopenshell.api.sequence.assign_process(model, relating_process=task, related_object=wall)
|
||||
"""
|
||||
settings = {
|
||||
"relating_process": relating_process,
|
||||
@@ -109,13 +109,13 @@ def assign_process(
|
||||
related_objects = list(operates_on.RelatedObjects)
|
||||
related_objects.append(settings["related_object"])
|
||||
operates_on.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": operates_on})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": operates_on})
|
||||
else:
|
||||
operates_on = file.create_entity(
|
||||
"IfcRelAssignsToProcess",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": [settings["related_object"]],
|
||||
"RelatingProcess": settings["relating_process"],
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
@@ -54,18 +54,18 @@ def assign_product(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's create a construction task. Note that the predefined type is
|
||||
# important to distinguish types of tasks.
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Build wall", identification="A", predefined_type="CONSTRUCTION")
|
||||
|
||||
# Let's say we have a wall somewhere.
|
||||
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
|
||||
# Let's construct that wall!
|
||||
ifcopenshell.api.run("sequence.assign_product", model, relating_product=wall, related_object=task)
|
||||
ifcopenshell.api.sequence.assign_product(model, relating_product=wall, related_object=task)
|
||||
"""
|
||||
settings = {
|
||||
"relating_product": relating_product,
|
||||
@@ -85,13 +85,13 @@ def assign_product(
|
||||
related_objects = list(referenced_by.RelatedObjects)
|
||||
related_objects.append(settings["related_object"])
|
||||
referenced_by.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": referenced_by})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": referenced_by})
|
||||
else:
|
||||
referenced_by = file.create_entity(
|
||||
"IfcRelAssignsToProduct",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": [settings["related_object"]],
|
||||
"RelatingProduct": settings["relating_product"],
|
||||
}
|
||||
|
||||
@@ -76,36 +76,36 @@ def assign_recurrence_pattern(
|
||||
.. code:: python
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model)
|
||||
|
||||
# Let's start defining the times that we work during the week.
|
||||
work_time = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
work_time = ifcopenshell.api.sequence.add_work_time(model,
|
||||
work_calendar=calendar, time_type="WorkingTimes")
|
||||
|
||||
# We create a weekly recurrence
|
||||
pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
|
||||
pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
|
||||
parent=work_time, recurrence_type="WEEKLY")
|
||||
|
||||
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday)
|
||||
ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
|
||||
ifcopenshell.api.sequence.edit_recurrence_pattern(model,
|
||||
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
|
||||
|
||||
# Let's imagine we are creating a maintenance schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Equipment Maintenance")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Equipment Maintenance")
|
||||
|
||||
# Now let's imagine we have a task to maintain the chillers
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Chiller maintenance")
|
||||
|
||||
# Because it is a maintenance task, we must schedule a recurring time
|
||||
time = ifcopenshell.api.run("sequence.add_task_time", model, task=task, is_recurring=True)
|
||||
time = ifcopenshell.api.sequence.add_task_time(model, task=task, is_recurring=True)
|
||||
|
||||
# We create a monthly recurrence
|
||||
pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
|
||||
pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
|
||||
parent=work_time, recurrence_type="MONTHLY_BY_DAY_OF_MONTH")
|
||||
|
||||
# Specifically, the maintenance task must occur every 6 months
|
||||
ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
|
||||
ifcopenshell.api.sequence.edit_recurrence_pattern(model,
|
||||
recurrence_pattern=pattern, attributes={"DayComponent": [1], "Interval": 6})
|
||||
"""
|
||||
settings = {"parent": parent, "recurrence_type": recurrence_type}
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
@@ -64,41 +65,41 @@ def assign_sequence(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's imagine a root construction task
|
||||
construction = ifcopenshell.api.run("sequence.add_task", model,
|
||||
construction = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
|
||||
# Let's imagine we're doing a typically formwork, reinforcement,
|
||||
# pour sequence. Let's start with the formwork. It'll take us 2
|
||||
# days.
|
||||
formwork = ifcopenshell.api.run("sequence.add_task", model,
|
||||
formwork = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Formwork", identification="C.1")
|
||||
time = ifcopenshell.api.run("sequence.add_task_time", model, task=formwork)
|
||||
ifcopenshell.api.run("sequence.edit_task_time", model,
|
||||
time = ifcopenshell.api.sequence.add_task_time(model, task=formwork)
|
||||
ifcopenshell.api.sequence.edit_task_time(model,
|
||||
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
|
||||
|
||||
# Now let's do the reinforcement. It'll take us another 2 days.
|
||||
reinforcement = ifcopenshell.api.run("sequence.add_task", model,
|
||||
reinforcement = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Reinforcement", identification="C.2")
|
||||
time = ifcopenshell.api.run("sequence.add_task_time", model, task=reinforcement)
|
||||
ifcopenshell.api.run("sequence.edit_task_time", model,
|
||||
time = ifcopenshell.api.sequence.add_task_time(model, task=reinforcement)
|
||||
ifcopenshell.api.sequence.edit_task_time(model,
|
||||
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
|
||||
|
||||
# Now the pour it It'll only take 1 day.
|
||||
pour = ifcopenshell.api.run("sequence.add_task", model,
|
||||
pour = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Reinforcement", identification="C.3")
|
||||
time = ifcopenshell.api.run("sequence.add_task_time", model, task=pour)
|
||||
ifcopenshell.api.run("sequence.edit_task_time", model,
|
||||
time = ifcopenshell.api.sequence.add_task_time(model, task=pour)
|
||||
ifcopenshell.api.sequence.edit_task_time(model,
|
||||
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P1D"})
|
||||
|
||||
# Now let's say the formwork must finish before the reinforcement
|
||||
# can start, and the reinforcement must finish before the pour can
|
||||
# start. This is a typical finish to start relationship (FS).
|
||||
ifcopenshell.api.run("sequence.assign_sequence", model,
|
||||
ifcopenshell.api.sequence.assign_sequence(model,
|
||||
relating_process=formwork, related_process=reinforcement)
|
||||
ifcopenshell.api.run("sequence.assign_sequence", model,
|
||||
ifcopenshell.api.sequence.assign_sequence(model,
|
||||
relating_process=reinforcement, related_process=pour)
|
||||
|
||||
# Notice how we set all the scheduled start dates arbitrarily at
|
||||
@@ -106,7 +107,7 @@ def assign_sequence(
|
||||
# automatically cascade the dates, starting from any task. This will
|
||||
# update the reinforcement date to be 2000-01-03 and the pour date
|
||||
# to be 2000-01-05.
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", model, task=formwork)
|
||||
ifcopenshell.api.sequence.cascade_schedule(model, task=formwork)
|
||||
"""
|
||||
settings = {
|
||||
"relating_process": relating_process,
|
||||
@@ -121,11 +122,11 @@ def assign_sequence(
|
||||
"IfcRelSequence",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatingProcess": settings["relating_process"],
|
||||
"RelatedProcess": settings["related_process"],
|
||||
"SequenceType": settings["sequence_type"],
|
||||
}
|
||||
)
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", file, task=settings["relating_process"])
|
||||
ifcopenshell.api.sequence.cascade_schedule(file, task=settings["relating_process"])
|
||||
return rel
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.aggregate
|
||||
|
||||
|
||||
def assign_work_plan(
|
||||
@@ -41,26 +42,24 @@ def assign_work_plan(
|
||||
.. code:: python
|
||||
|
||||
# This will hold all our construction schedules
|
||||
work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
|
||||
work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
|
||||
|
||||
# Alternatively, if you create a schedule without a work plan ...
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# ... you can assign the work plan afterwards.
|
||||
ifcopenshell.api.run("sequence.assign_work_plan", work_schedule=schedule, work_plan=work_plan)
|
||||
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.run(
|
||||
"project.unassign_declaration",
|
||||
ifcopenshell.api.project.unassign_declaration(
|
||||
file,
|
||||
definitions=[settings["work_schedule"]],
|
||||
relating_context=file.by_type("IfcContext")[0],
|
||||
)
|
||||
rel_aggregates = ifcopenshell.api.run(
|
||||
"aggregate.assign_object",
|
||||
rel_aggregates = ifcopenshell.api.aggregate.assign_object(
|
||||
file,
|
||||
**{
|
||||
"products": [settings["work_schedule"]],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import math
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.util.date
|
||||
import ifcopenshell.util.element
|
||||
|
||||
@@ -44,41 +44,41 @@ def calculate_task_duration(file: ifcopenshell.file, task: ifcopenshell.entity_i
|
||||
.. code:: python
|
||||
|
||||
# Add our own crew
|
||||
crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
|
||||
crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
|
||||
|
||||
# Add some labour to our crew.
|
||||
labour = ifcopenshell.api.run("resource.add_resource", model,
|
||||
labour = ifcopenshell.api.resource.add_resource(model,
|
||||
parent_resource=crew, ifc_class="IfcLaborResource")
|
||||
|
||||
# Labour resource is quantified in terms of time.
|
||||
quantity = ifcopenshell.api.run("resource.add_resource_quantity", model,
|
||||
quantity = ifcopenshell.api.resource.add_resource_quantity(model,
|
||||
resource=labour, ifc_class="IfcQuantityTime")
|
||||
|
||||
# Store the unit time used in hours
|
||||
ifcopenshell.api.run("resource.edit_resource_quantity", model,
|
||||
ifcopenshell.api.resource.edit_resource_quantity(model,
|
||||
physical_quantity=quantity, attributes={"TimeValue": 8.0})
|
||||
|
||||
# Let's imagine we've used the resource for 10 days with a
|
||||
# utilisation of 200%.
|
||||
time = ifcopenshell.api.run("resource.add_resource_time", model, resource=labour)
|
||||
ifcopenshell.api.run("resource.edit_resource_time", model,
|
||||
time = ifcopenshell.api.resource.add_resource_time(model, resource=labour)
|
||||
ifcopenshell.api.resource.edit_resource_time(model,
|
||||
resource_time=time, attributes={"ScheduleWork": "PT80H", "ScheduleUsage": 2})
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's create a construction task. Note that the predefined type is
|
||||
# important to distinguish types of tasks.
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Foundations", identification="A")
|
||||
|
||||
# Assign our resource to the task.
|
||||
ifcopenshell.api.run("sequence.assign_process", model, relating_process=task, related_object=labour)
|
||||
ifcopenshell.api.sequence.assign_process(model, relating_process=task, related_object=labour)
|
||||
|
||||
# Now we can calculate the task duration based on the resource. This
|
||||
# will set task.TaskTime.ScheduleDuration to be P5D.
|
||||
ifcopenshell.api.run("sequence.calculate_task_duration", model, task=task)
|
||||
ifcopenshell.api.sequence.calculate_task_duration(model, task=task)
|
||||
"""
|
||||
usecase = Usecase()
|
||||
usecase.file = file
|
||||
@@ -142,5 +142,5 @@ class Usecase:
|
||||
|
||||
def set_task_duration(self, duration):
|
||||
if not self.settings["task"].TaskTime:
|
||||
ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.settings["task"])
|
||||
ifcopenshell.api.sequence.add_task_time(self.file, task=self.settings["task"])
|
||||
self.settings["task"].TaskTime.ScheduleDuration = f"P{duration}D"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.api.control
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.sequence
|
||||
@@ -49,13 +51,14 @@ def create_baseline(
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
Example:
|
||||
|
||||
.. code:: python
|
||||
|
||||
# We have a Work Schedule
|
||||
planned_work_schedule = WorkSchedule(name="Design new feature",predefinedType="PLANNED", deadline="2023-03-01")
|
||||
|
||||
# And now we have a baseline for our Work Schedule
|
||||
baseline_work_schedule = ifcopenshell.api.run("sequence.create_baseline",file, work_schedule= planned_work_schedule, name="Baseline 1")
|
||||
baseline_work_schedule = ifcopenshell.api.sequence.create_baseline(file, work_schedule=planned_work_schedule, name="Baseline 1")
|
||||
"""
|
||||
usecase = Usecase()
|
||||
usecase.file = file
|
||||
@@ -72,25 +75,15 @@ class Usecase:
|
||||
# create work schedule
|
||||
if not work_schedule.PredefinedType == "PLANNED":
|
||||
return
|
||||
baseline_work_schedule = ifcopenshell.api.run(
|
||||
"sequence.add_work_schedule",
|
||||
self.file,
|
||||
name=work_schedule.Name,
|
||||
predefined_type="BASELINE",
|
||||
baseline_work_schedule = ifcopenshell.api.sequence.add_work_schedule(
|
||||
self.file, name=work_schedule.Name, predefined_type="BASELINE"
|
||||
)
|
||||
baseline_work_schedule.Name = self.settings["name"]
|
||||
self.create_baseline_reference(work_schedule, baseline_work_schedule)
|
||||
for summary_task in ifcopenshell.util.sequence.get_root_tasks(work_schedule):
|
||||
current, duplicate = ifcopenshell.api.run(
|
||||
"sequence.duplicate_task",
|
||||
self.file,
|
||||
task=summary_task,
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"control.assign_control",
|
||||
self.file,
|
||||
relating_control=baseline_work_schedule,
|
||||
related_object=duplicate[0],
|
||||
current, duplicate = ifcopenshell.api.sequence.duplicate_task(self.file, task=summary_task)
|
||||
ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=baseline_work_schedule, related_object=duplicate[0]
|
||||
)
|
||||
for i, task in enumerate(current):
|
||||
self.create_baseline_reference(task, duplicate[i])
|
||||
@@ -103,15 +96,13 @@ class Usecase:
|
||||
related_objects = list(referenced_by.RelatedObjects)
|
||||
related_objects.append(related_object)
|
||||
referenced_by.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": referenced_by})
|
||||
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": referenced_by})
|
||||
else:
|
||||
referenced_by = self.file.create_entity(
|
||||
"IfcRelDefinesByObject",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
"RelatedObjects": [related_object],
|
||||
"RelatingObject": relating_object,
|
||||
}
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
|
||||
RelatedObjects=[related_object],
|
||||
RelatingObject=relating_object,
|
||||
)
|
||||
return referenced_by
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.nest
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.sequence
|
||||
|
||||
@@ -83,9 +85,8 @@ class Usecase:
|
||||
inverse = ifcopenshell.util.element.copy(self.file, inverse)
|
||||
inverse.RelatingObject = to_element
|
||||
inverse.RelatedObjects = new_tasks
|
||||
ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=new_tasks)
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object",
|
||||
ifcopenshell.api.nest.unassign_object(self.file, related_objects=new_tasks)
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
self.file,
|
||||
related_objects=new_tasks,
|
||||
relating_object=to_element,
|
||||
@@ -133,15 +134,13 @@ class Usecase:
|
||||
else: # thus the relating process is not part of the duplicated tasks
|
||||
relating_process = inverse.RelatingProcess
|
||||
if relating_process and related_process:
|
||||
rel = ifcopenshell.api.run(
|
||||
"sequence.assign_sequence",
|
||||
rel = ifcopenshell.api.sequence.assign_sequence(
|
||||
self.file,
|
||||
relating_process=relating_process,
|
||||
related_process=related_process,
|
||||
)
|
||||
if inverse.TimeLag:
|
||||
ifcopenshell.api.run(
|
||||
"sequence.assign_lag_time",
|
||||
ifcopenshell.api.sequence.assign_lag_time(
|
||||
self.file,
|
||||
rel_sequence=rel,
|
||||
lag_value=(
|
||||
@@ -160,13 +159,13 @@ class Usecase:
|
||||
related_objects = list(referenced_by.RelatedObjects)
|
||||
related_objects.append(related_object)
|
||||
referenced_by.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": referenced_by})
|
||||
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": referenced_by})
|
||||
else:
|
||||
referenced_by = self.file.create_entity(
|
||||
"IfcRelDefinesByObject",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(self.file),
|
||||
"RelatedObjects": [related_object],
|
||||
"RelatingObject": relating_object,
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.util.date
|
||||
from typing import Any
|
||||
|
||||
@@ -40,40 +40,40 @@ def edit_lag_time(file: ifcopenshell.file, lag_time: ifcopenshell.entity_instanc
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's imagine a root construction task
|
||||
construction = ifcopenshell.api.run("sequence.add_task", model,
|
||||
construction = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
|
||||
# Let's imagine we're doing a typically formwork, reinforcement,
|
||||
# pour sequence. Let's start with the formwork. It'll take us 2
|
||||
# days.
|
||||
formwork = ifcopenshell.api.run("sequence.add_task", model,
|
||||
formwork = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Formwork", identification="C.1")
|
||||
time = ifcopenshell.api.run("sequence.add_task_time", model, task=formwork)
|
||||
ifcopenshell.api.run("sequence.edit_task_time", model,
|
||||
time = ifcopenshell.api.sequence.add_task_time(model, task=formwork)
|
||||
ifcopenshell.api.sequence.edit_task_time(model,
|
||||
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
|
||||
|
||||
# Now let's do the reinforcement. It'll take us another 2 days.
|
||||
reinforcement = ifcopenshell.api.run("sequence.add_task", model,
|
||||
reinforcement = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Reinforcement", identification="C.2")
|
||||
time = ifcopenshell.api.run("sequence.add_task_time", model, task=reinforcement)
|
||||
ifcopenshell.api.run("sequence.edit_task_time", model,
|
||||
time = ifcopenshell.api.sequence.add_task_time(model, task=reinforcement)
|
||||
ifcopenshell.api.sequence.edit_task_time(model,
|
||||
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
|
||||
|
||||
# Now let's say the formwork must finish before the reinforcement
|
||||
# can start. This is a typical finish to start relationship (FS).
|
||||
sequence = ifcopenshell.api.run("sequence.assign_sequence", model,
|
||||
sequence = ifcopenshell.api.sequence.assign_sequence(model,
|
||||
relating_process=formwork, related_process=reinforcement)
|
||||
|
||||
# Now typically there would be no lag time between formwork and
|
||||
# reinforcement, but let's pretend that we had to allow 1 day gap
|
||||
# for whatever reason.
|
||||
lag = ifcopenshell.api.run("sequence.assign_lag_time", model, rel_sequence=sequence, lag_value="P1D")
|
||||
lag = ifcopenshell.api.sequence.assign_lag_time(model, rel_sequence=sequence, lag_value="P1D")
|
||||
|
||||
# Or, let's make it 2 days instead.
|
||||
ifcopenshell.api.run("sequence.edit_lag_time", model, lag_time=lag, attributes={"LagValue": "P2D"})
|
||||
ifcopenshell.api.sequence.edit_lag_time(model, lag_time=lag, attributes={"LagValue": "P2D"})
|
||||
"""
|
||||
settings = {"lag_time": lag_time, "attributes": attributes}
|
||||
|
||||
@@ -85,4 +85,4 @@ def edit_lag_time(file: ifcopenshell.file, lag_time: ifcopenshell.entity_instanc
|
||||
value = file.createIfcDuration(ifcopenshell.util.date.datetime2ifc(value, "IfcDuration"))
|
||||
setattr(settings["lag_time"], name, value)
|
||||
for rel in [r for r in file.get_inverse(settings["lag_time"]) if r.is_a("IfcRelSequence")]:
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", file, task=rel.RelatedProcess)
|
||||
ifcopenshell.api.sequence.cascade_schedule(file, task=rel.RelatedProcess)
|
||||
|
||||
@@ -41,18 +41,18 @@ def edit_recurrence_pattern(
|
||||
.. code:: python
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model)
|
||||
|
||||
# Let's start defining the times that we work during the week.
|
||||
work_time = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
work_time = ifcopenshell.api.sequence.add_work_time(model,
|
||||
work_calendar=calendar, time_type="WorkingTimes")
|
||||
|
||||
# We create a weekly recurrence
|
||||
pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
|
||||
pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
|
||||
parent=work_time, recurrence_type="WEEKLY")
|
||||
|
||||
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday)
|
||||
ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
|
||||
ifcopenshell.api.sequence.edit_recurrence_pattern(model,
|
||||
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
|
||||
"""
|
||||
settings = {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.sequence
|
||||
from typing import Any
|
||||
|
||||
|
||||
@@ -42,24 +42,24 @@ def edit_sequence(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's imagine a root construction task
|
||||
construction = ifcopenshell.api.run("sequence.add_task", model,
|
||||
construction = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
|
||||
# Let's imagine we're building 2 zones, one after another.
|
||||
zone1 = ifcopenshell.api.run("sequence.add_task", model,
|
||||
zone1 = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Zone 1", identification="C.1")
|
||||
zone2 = ifcopenshell.api.run("sequence.add_task", model,
|
||||
zone2 = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Zone 2", identification="C.2")
|
||||
|
||||
# Zone 1 finishes, then zone 2 starts.
|
||||
sequence = ifcopenshell.api.run("sequence.assign_sequence", model,
|
||||
sequence = ifcopenshell.api.sequence.assign_sequence(model,
|
||||
relating_process=zone1, related_process=zone2)
|
||||
|
||||
# What if they both started at the same time?
|
||||
ifcopenshell.api.run("sequence.edit_sequence", model,
|
||||
ifcopenshell.api.sequence.edit_sequence(model,
|
||||
rel_sequence=sequence, attributes={"SequenceType": "START_START"})
|
||||
"""
|
||||
settings = {"rel_sequence": rel_sequence, "attributes": attributes}
|
||||
@@ -67,8 +67,4 @@ def edit_sequence(
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["rel_sequence"], name, value)
|
||||
if "SequenceType" in settings["attributes"].keys():
|
||||
ifcopenshell.api.run(
|
||||
"sequence.cascade_schedule",
|
||||
file,
|
||||
task=settings["rel_sequence"].RelatedProcess,
|
||||
)
|
||||
ifcopenshell.api.sequence.cascade_schedule(file, task=settings["rel_sequence"].RelatedProcess)
|
||||
|
||||
@@ -38,15 +38,15 @@ def edit_task(file: ifcopenshell.file, task: ifcopenshell.entity_instance, attri
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Add a root task to represent the design milestones, and major
|
||||
# project phases.
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Milestones", identification="A")
|
||||
|
||||
# Change the identification
|
||||
ifcopenshell.api.run("sequence.edit_task", model, task=task, attributes={"Identification": "M"})
|
||||
ifcopenshell.api.sequence.edit_task(model, task=task, attributes={"Identification": "M"})
|
||||
"""
|
||||
settings = {"task": task, "attributes": attributes or {}}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import datetime
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.api.resource
|
||||
import ifcopenshell.util.constraint
|
||||
import ifcopenshell.util.date
|
||||
import ifcopenshell.util.sequence
|
||||
@@ -46,15 +48,15 @@ def edit_task_time(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Create a task to do formwork
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Formwork", identification="A")
|
||||
|
||||
# Let's say it takes 2 days and starts on the 1st of January, 2000
|
||||
time = ifcopenshell.api.run("sequence.add_task_time", model, task=formwork)
|
||||
ifcopenshell.api.run("sequence.edit_task_time", model,
|
||||
time = ifcopenshell.api.sequence.add_task_time(model, task=formwork)
|
||||
ifcopenshell.api.sequence.edit_task_time(model,
|
||||
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
|
||||
"""
|
||||
usecase = Usecase()
|
||||
@@ -117,7 +119,7 @@ class Usecase:
|
||||
or "ScheduleFinish" in self.settings["attributes"].keys()
|
||||
or "ScheduleDuration" in self.settings["attributes"].keys()
|
||||
):
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=self.task)
|
||||
ifcopenshell.api.sequence.cascade_schedule(self.file, task=self.task)
|
||||
if self.settings["task_time"].ScheduleDuration:
|
||||
self.handle_resource_calculation()
|
||||
|
||||
@@ -152,7 +154,7 @@ class Usecase:
|
||||
resources = ifcopenshell.util.sequence.get_task_resources(self.task, is_deep=False)
|
||||
for resource in resources:
|
||||
if ifcopenshell.util.constraint.is_attribute_locked(resource, "Usage.ScheduleWork"):
|
||||
ifcopenshell.api.run("resource.calculate_resource_usage", self.file, resource=resource)
|
||||
ifcopenshell.api.resource.calculate_resource_usage(self.file, resource=resource)
|
||||
# TODO: If the duration changes, this implies the productivity rate must change to accomModate the new Schedule Work to be calculated.
|
||||
# elif ifcopenshell.util.constraint.is_attribute_locked(resource, "Usage.ScheduleUsage"):
|
||||
# ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
|
||||
# ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
|
||||
|
||||
@@ -39,10 +39,10 @@ def edit_work_calendar(
|
||||
.. code:: python
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model, name="5 Day Week")
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model, name="5 Day Week")
|
||||
|
||||
# Let's give it a description
|
||||
ifcopenshell.api.run("sequence.edit_work_calendar", model,
|
||||
ifcopenshell.api.sequence.edit_work_calendar(model,
|
||||
work_calendar=calendar, attributes={"Description": "Monday to Friday 8 hour days"})
|
||||
"""
|
||||
settings = {"work_calendar": work_calendar, "attributes": attributes}
|
||||
|
||||
@@ -40,10 +40,10 @@ def edit_work_plan(
|
||||
.. code:: python
|
||||
|
||||
# This will hold all our construction schedules
|
||||
work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
|
||||
work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
|
||||
|
||||
# Let's give it a description
|
||||
ifcopenshell.api.run("sequence.edit_work_plan", model,
|
||||
ifcopenshell.api.sequence.edit_work_plan(model,
|
||||
work_plan=work_plan, attributes={"Description": "Construction of phase 1"})
|
||||
"""
|
||||
settings = {"work_plan": work_plan, "attributes": attributes}
|
||||
|
||||
@@ -40,14 +40,14 @@ def edit_work_schedule(
|
||||
.. code:: python
|
||||
|
||||
# This will hold all our construction schedules
|
||||
work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
|
||||
work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
|
||||
|
||||
# Let's imagine this is one of our schedules in our work plan.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model,
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model,
|
||||
name="Construction Schedule A", work_plan=work_plan)
|
||||
|
||||
# Let's give it a description
|
||||
ifcopenshell.api.run("sequence.edit_work_schedule", model,
|
||||
ifcopenshell.api.sequence.edit_work_schedule(model,
|
||||
work_schedule=work_schedule, attributes={"Description": "3 crane design option"})
|
||||
"""
|
||||
settings = {"work_schedule": work_schedule, "attributes": attributes}
|
||||
|
||||
@@ -42,16 +42,16 @@ def edit_work_time(
|
||||
.. code:: python
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model)
|
||||
|
||||
# Let's start defining the times that we work during the week.
|
||||
work_time = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
work_time = ifcopenshell.api.sequence.add_work_time(model,
|
||||
work_calendar=calendar, time_type="WorkingTimes")
|
||||
|
||||
# If we don't specify any recurring time periods in our work time,
|
||||
# we need to specify a start and end date of the work time. It
|
||||
# starts at 0:00 on the start date and 24:00 at the end date.
|
||||
ifcopenshell.api.run("sequence.edit_work_time", model,
|
||||
ifcopenshell.api.sequence.edit_work_time(model,
|
||||
work_time=work_time, attributes={"StartDate": "2000-01-01", "FinishDate": "2000-01-02"})
|
||||
"""
|
||||
settings = {"work_time": work_time, "attributes": attributes}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
import datetime
|
||||
import networkx as nx
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.util.date
|
||||
import ifcopenshell.util.sequence
|
||||
|
||||
@@ -184,8 +184,7 @@ class Usecase:
|
||||
task = self.file.by_id(ifc_definition_id)
|
||||
if not task.TaskTime:
|
||||
continue
|
||||
ifcopenshell.api.run(
|
||||
"sequence.edit_task_time",
|
||||
ifcopenshell.api.sequence.edit_task_time(
|
||||
self.file,
|
||||
task_time=task.TaskTime,
|
||||
attributes={
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.nest
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.util.element
|
||||
|
||||
@@ -40,26 +41,25 @@ def remove_task(file: ifcopenshell.file, task: ifcopenshell.entity_instance) ->
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Add a root task to represent the design milestones, and major
|
||||
# project phases.
|
||||
ifcopenshell.api.run("sequence.add_task", model,
|
||||
ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Milestones", identification="A")
|
||||
design = ifcopenshell.api.run("sequence.add_task", model,
|
||||
design = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Design", identification="B")
|
||||
ifcopenshell.api.run("sequence.add_task", model,
|
||||
ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
|
||||
# Ah, let's delete the design section, who needs it anyway we'll
|
||||
# just fix it on site.
|
||||
ifcopenshell.api.run("sequence.remove_task", model, task=design)
|
||||
ifcopenshell.api.sequence.remove_task(model, task=design)
|
||||
"""
|
||||
settings = {"task": task}
|
||||
|
||||
# TODO: do a deep purge
|
||||
ifcopenshell.api.run(
|
||||
"project.unassign_declaration",
|
||||
ifcopenshell.api.project.unassign_declaration(
|
||||
file,
|
||||
definitions=[settings["task"]],
|
||||
relating_context=file.by_type("IfcContext")[0],
|
||||
@@ -75,7 +75,7 @@ def remove_task(file: ifcopenshell.file, task: ifcopenshell.entity_instance) ->
|
||||
# Use batching for optimization.
|
||||
ifcopenshell.api.nest.unassign_object(file, subtasks)
|
||||
for task_ in subtasks:
|
||||
ifcopenshell.api.run("sequence.remove_task", file, task=task_)
|
||||
ifcopenshell.api.sequence.remove_task(file, task=task_)
|
||||
if settings["task"].Nests:
|
||||
ifcopenshell.api.nest.unassign_object(file, [settings["task"]])
|
||||
|
||||
@@ -96,8 +96,7 @@ def remove_task(file: ifcopenshell.file, task: ifcopenshell.entity_instance) ->
|
||||
related_objects.remove(settings["task"])
|
||||
inverse.RelatedObjects = related_objects
|
||||
elif inverse.is_a("IfcRelDefinesByProperties"):
|
||||
ifcopenshell.api.run(
|
||||
"pset.remove_pset",
|
||||
ifcopenshell.api.pset.remove_pset(
|
||||
file,
|
||||
product=settings["task"],
|
||||
pset=inverse.RelatingPropertyDefinition,
|
||||
|
||||
@@ -32,28 +32,28 @@ def remove_time_period(file: ifcopenshell.file, time_period: ifcopenshell.entity
|
||||
.. code:: python
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model)
|
||||
|
||||
# Let's start defining the times that we work during the week.
|
||||
work_time = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
work_time = ifcopenshell.api.sequence.add_work_time(model,
|
||||
work_calendar=calendar, time_type="WorkingTimes")
|
||||
|
||||
# We create a weekly recurrence
|
||||
pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
|
||||
pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
|
||||
parent=work_time, recurrence_type="WEEKLY")
|
||||
|
||||
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday)
|
||||
ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
|
||||
ifcopenshell.api.sequence.edit_recurrence_pattern(model,
|
||||
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
|
||||
|
||||
# The morning work session, lunch, then the afternoon work session.
|
||||
morning = ifcopenshell.api.run("sequence.add_time_period", model,
|
||||
morning = ifcopenshell.api.sequence.add_time_period(model,
|
||||
recurrence_pattern=pattern, start_time="09:00", end_time="12:00")
|
||||
afternoon = ifcopenshell.api.run("sequence.add_time_period", model,
|
||||
afternoon = ifcopenshell.api.sequence.add_time_period(model,
|
||||
recurrence_pattern=pattern, start_time="13:00", end_time="17:00")
|
||||
|
||||
# Let's take the afternoon off!
|
||||
ifcopenshell.api.run("sequence.remove_time_period", model, time_period=afternoon)
|
||||
ifcopenshell.api.sequence.remove_time_period(model, time_period=afternoon)
|
||||
"""
|
||||
settings = {"time_period": time_period}
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.control
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.util.element
|
||||
|
||||
@@ -38,16 +39,15 @@ def remove_work_calendar(file: ifcopenshell.file, work_calendar: ifcopenshell.en
|
||||
.. code:: python
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model, name="5 Day Week")
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model, name="5 Day Week")
|
||||
|
||||
# And remove it immediately
|
||||
ifcopenshell.api.run("sequence.remove_work_calendar", model, work_calendar=calendar)
|
||||
ifcopenshell.api.sequence.remove_work_calendar(model, work_calendar=calendar)
|
||||
"""
|
||||
settings = {"work_calendar": work_calendar}
|
||||
|
||||
# TODO: do a deep purge
|
||||
ifcopenshell.api.run(
|
||||
"project.unassign_declaration",
|
||||
ifcopenshell.api.project.unassign_declaration(
|
||||
file,
|
||||
definitions=[settings["work_calendar"]],
|
||||
relating_context=file.by_type("IfcContext")[0],
|
||||
@@ -55,8 +55,7 @@ def remove_work_calendar(file: ifcopenshell.file, work_calendar: ifcopenshell.en
|
||||
if settings["work_calendar"].Controls:
|
||||
for rel in settings["work_calendar"].Controls:
|
||||
for related_object in rel.RelatedObjects:
|
||||
ifcopenshell.api.run(
|
||||
"control.unassign_control",
|
||||
ifcopenshell.api.control.unassign_control(
|
||||
file,
|
||||
relating_control=settings["work_calendar"],
|
||||
related_object=related_object,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.util.element
|
||||
|
||||
@@ -38,15 +38,14 @@ def remove_work_plan(file: ifcopenshell.file, work_plan: ifcopenshell.entity_ins
|
||||
.. code:: python
|
||||
|
||||
# This will hold all our construction schedules
|
||||
work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
|
||||
work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
|
||||
|
||||
# And remove it immediately
|
||||
ifcopenshell.api.run("sequence.remove_work_plan", model, work_plan=work_plan)
|
||||
ifcopenshell.api.sequence.remove_work_plan(model, work_plan=work_plan)
|
||||
"""
|
||||
settings = {"work_plan": work_plan}
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"project.unassign_declaration",
|
||||
ifcopenshell.api.project.unassign_declaration(
|
||||
file,
|
||||
definitions=[settings["work_plan"]],
|
||||
relating_context=file.by_type("IfcContext")[0],
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.util.element
|
||||
|
||||
@@ -37,33 +38,26 @@ def remove_work_schedule(file: ifcopenshell.file, work_schedule: ifcopenshell.en
|
||||
.. code:: python
|
||||
|
||||
# This will hold all our construction schedules
|
||||
work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
|
||||
work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
|
||||
|
||||
# Let's imagine this is one of our schedules in our work plan.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model,
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model,
|
||||
name="Construction Schedule A", work_plan=work_plan)
|
||||
|
||||
# And remove it immediately
|
||||
ifcopenshell.api.run("sequence.remove_work_schedule", model, work_schedule=schedule)
|
||||
ifcopenshell.api.sequence.remove_work_schedule(model, work_schedule=schedule)
|
||||
"""
|
||||
settings = {"work_schedule": work_schedule}
|
||||
|
||||
# TODO: do a deep purge
|
||||
ifcopenshell.api.run(
|
||||
"project.unassign_declaration",
|
||||
file,
|
||||
definitions=[settings["work_schedule"]],
|
||||
relating_context=file.by_type("IfcContext")[0],
|
||||
ifcopenshell.api.project.unassign_declaration(
|
||||
file, definitions=[settings["work_schedule"]], relating_context=file.by_type("IfcContext")[0]
|
||||
)
|
||||
|
||||
if settings["work_schedule"].Declares:
|
||||
for rel in settings["work_schedule"].Declares:
|
||||
for work_schedule in rel.RelatedObjects:
|
||||
ifcopenshell.api.run(
|
||||
"sequence.remove_work_schedule",
|
||||
file,
|
||||
work_schedule=work_schedule,
|
||||
)
|
||||
ifcopenshell.api.sequence.remove_work_schedule(file, work_schedule=work_schedule)
|
||||
|
||||
# Unassign from work plans.
|
||||
if settings["work_schedule"].Decomposes:
|
||||
@@ -82,7 +76,7 @@ def remove_work_schedule(file: ifcopenshell.file, work_schedule: ifcopenshell.en
|
||||
inverse.RelatedObjects = related_objects
|
||||
elif inverse.is_a("IfcRelAssignsToControl"):
|
||||
[
|
||||
ifcopenshell.api.run("sequence.remove_task", file, task=related_object)
|
||||
ifcopenshell.api.sequence.remove_task(file, task=related_object)
|
||||
for related_object in inverse.RelatedObjects
|
||||
if related_object.is_a("IfcTask")
|
||||
]
|
||||
|
||||
@@ -32,14 +32,14 @@ def remove_work_time(file: ifcopenshell.file, work_time: ifcopenshell.entity_ins
|
||||
.. code:: python
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model)
|
||||
|
||||
# Let's start defining the times that we work during the week.
|
||||
work_time = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
work_time = ifcopenshell.api.sequence.add_work_time(model,
|
||||
work_calendar=calendar, time_type="WorkingTimes")
|
||||
|
||||
# And remove it immediately
|
||||
ifcopenshell.api.run("sequence.remove_work_time", model, work_time=work_time)
|
||||
ifcopenshell.api.sequence.remove_work_time(model, work_time=work_time)
|
||||
"""
|
||||
|
||||
# Currently in API recurrence patterns are created during assignment
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.sequence
|
||||
|
||||
|
||||
def unassign_lag_time(file: ifcopenshell.file, rel_sequence: ifcopenshell.entity_instance) -> None:
|
||||
@@ -35,27 +35,27 @@ def unassign_lag_time(file: ifcopenshell.file, rel_sequence: ifcopenshell.entity
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's imagine a root construction task
|
||||
construction = ifcopenshell.api.run("sequence.add_task", model,
|
||||
construction = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
|
||||
# Let's imagine we're building 2 zones, one after another.
|
||||
zone1 = ifcopenshell.api.run("sequence.add_task", model,
|
||||
zone1 = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Zone 1", identification="C.1")
|
||||
zone2 = ifcopenshell.api.run("sequence.add_task", model,
|
||||
zone2 = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Zone 2", identification="C.2")
|
||||
|
||||
# Zone 1 finishes, then zone 2 starts.
|
||||
sequence = ifcopenshell.api.run("sequence.assign_sequence", model,
|
||||
sequence = ifcopenshell.api.sequence.assign_sequence(model,
|
||||
relating_process=zone1, related_process=zone2)
|
||||
|
||||
# What if you had to wait 1 week before you could start zone 2?
|
||||
ifcopenshell.api.run("sequence.assign_lag_time", model, rel_sequence=sequence, lag_value="P1W")
|
||||
ifcopenshell.api.sequence.assign_lag_time(model, rel_sequence=sequence, lag_value="P1W")
|
||||
|
||||
# What if you didn't?
|
||||
ifcopenshell.api.run("sequence.unassign_lag_time", model, rel_sequence=sequence)
|
||||
ifcopenshell.api.sequence.unassign_lag_time(model, rel_sequence=sequence)
|
||||
"""
|
||||
settings = {
|
||||
"rel_sequence": rel_sequence,
|
||||
@@ -65,8 +65,4 @@ def unassign_lag_time(file: ifcopenshell.file, rel_sequence: ifcopenshell.entity
|
||||
file.remove(settings["rel_sequence"].TimeLag)
|
||||
else:
|
||||
settings["rel_sequence"].TimeLag = None
|
||||
ifcopenshell.api.run(
|
||||
"sequence.cascade_schedule",
|
||||
file,
|
||||
task=settings["rel_sequence"].RelatedProcess,
|
||||
)
|
||||
ifcopenshell.api.sequence.cascade_schedule(file, task=settings["rel_sequence"].RelatedProcess)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -43,21 +43,21 @@ def unassign_process(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's create a construction task. Note that the predefined type is
|
||||
# important to distinguish types of tasks.
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Demolish existing", identification="A", predefined_type="DEMOLITION")
|
||||
|
||||
# Let's say we have a wall somewhere.
|
||||
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
|
||||
# Let's demolish that wall!
|
||||
ifcopenshell.api.run("sequence.assign_process", model, relating_process=task, related_object=wall)
|
||||
ifcopenshell.api.sequence.assign_process(model, relating_process=task, related_object=wall)
|
||||
|
||||
# Change our mind.
|
||||
ifcopenshell.api.run("sequence.unassign_process", model, relating_process=task, related_object=wall)
|
||||
ifcopenshell.api.sequence.unassign_process(model, relating_process=task, related_object=wall)
|
||||
"""
|
||||
settings = {
|
||||
"relating_process": relating_process,
|
||||
@@ -76,5 +76,5 @@ def unassign_process(
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, element=rel)
|
||||
ifcopenshell.api.owner.update_owner_history(file, element=rel)
|
||||
return rel
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -43,21 +43,21 @@ def unassign_product(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's create a construction task. Note that the predefined type is
|
||||
# important to distinguish types of tasks.
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Build wall", identification="A", predefined_type="CONSTRUCTION")
|
||||
|
||||
# Let's say we have a wall somewhere.
|
||||
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
|
||||
# Let's construct that wall!
|
||||
ifcopenshell.api.run("sequence.assign_product", relating_product=wall, related_object=task)
|
||||
ifcopenshell.api.sequence.assign_product(relating_product=wall, related_object=task)
|
||||
|
||||
# Change our mind.
|
||||
ifcopenshell.api.run("sequence.unassign_product", relating_product=wall, related_object=task)
|
||||
ifcopenshell.api.sequence.unassign_product(relating_product=wall, related_object=task)
|
||||
"""
|
||||
settings = {
|
||||
"relating_product": relating_product,
|
||||
@@ -76,5 +76,5 @@ def unassign_product(
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, element=rel)
|
||||
ifcopenshell.api.owner.update_owner_history(file, element=rel)
|
||||
return rel
|
||||
|
||||
@@ -37,18 +37,18 @@ def unassign_recurrence_pattern(file: ifcopenshell.file, recurrence_pattern: ifc
|
||||
.. code:: python
|
||||
|
||||
# Let's create a new calendar.
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model)
|
||||
|
||||
# Let's start defining the times that we work during the week.
|
||||
work_time = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
work_time = ifcopenshell.api.sequence.add_work_time(model,
|
||||
work_calendar=calendar, time_type="WorkingTimes")
|
||||
|
||||
# We create a weekly recurrence
|
||||
pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
|
||||
pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
|
||||
parent=work_time, recurrence_type="WEEKLY")
|
||||
|
||||
# Change our mind, let's just maintain it whenever we feel like it.
|
||||
ifcopenshell.api.run("sequence.unassign_recurrence_pattern", recurrence_pattern=pattern)
|
||||
ifcopenshell.api.sequence.unassign_recurrence_pattern(recurrence_pattern=pattern)
|
||||
"""
|
||||
settings = {"recurrence_pattern": recurrence_pattern}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -41,23 +41,23 @@ def unassign_sequence(
|
||||
|
||||
# Let's imagine we are creating a construction schedule. All tasks
|
||||
# need to be part of a work schedule.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
|
||||
|
||||
# Let's imagine a root construction task
|
||||
construction = ifcopenshell.api.run("sequence.add_task", model,
|
||||
construction = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule, name="Construction", identification="C")
|
||||
|
||||
# Let's imagine we're building 2 zones, one after another.
|
||||
zone1 = ifcopenshell.api.run("sequence.add_task", model,
|
||||
zone1 = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Zone 1", identification="C.1")
|
||||
zone2 = ifcopenshell.api.run("sequence.add_task", model,
|
||||
zone2 = ifcopenshell.api.sequence.add_task(model,
|
||||
parent_task=construction, name="Zone 2", identification="C.2")
|
||||
|
||||
# Zone 1 finishes, then zone 2 starts.
|
||||
ifcopenshell.api.run("sequence.assign_sequence", model, relating_process=zone1, related_process=zone2)
|
||||
ifcopenshell.api.sequence.assign_sequence(model, relating_process=zone1, related_process=zone2)
|
||||
|
||||
# Let's make them unrelated
|
||||
ifcopenshell.api.run("sequence.unassign_sequence", model,
|
||||
ifcopenshell.api.sequence.unassign_sequence(model,
|
||||
relating_process=zone1, related_process=zone2)
|
||||
"""
|
||||
settings = {
|
||||
@@ -71,4 +71,4 @@ def unassign_sequence(
|
||||
file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", file, task=settings["related_process"])
|
||||
ifcopenshell.api.sequence.cascade_schedule(file, task=settings["related_process"])
|
||||
|
||||
Reference in New Issue
Block a user