mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Fix bug where calendar caching meant invalid duration calculations if you edited your calendar after a date calculation.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.date
|
||||
import ifcopenshell.util.sequence
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
@@ -93,4 +94,8 @@ class Usecase:
|
||||
time_periods = list(self.settings["recurrence_pattern"].TimePeriods or [])
|
||||
time_periods.append(time_period)
|
||||
self.settings["recurrence_pattern"].TimePeriods = time_periods
|
||||
|
||||
ifcopenshell.util.sequence.is_working_day.cache_clear()
|
||||
ifcopenshell.util.sequence.is_calendar_applicable.cache_clear()
|
||||
|
||||
return time_period
|
||||
|
||||
@@ -16,6 +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
|
||||
import ifcopenshell.util.sequence
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, recurrence_pattern=None, attributes=None):
|
||||
@@ -56,3 +59,6 @@ class Usecase:
|
||||
def execute(self):
|
||||
for name, value in self.settings["attributes"].items():
|
||||
setattr(self.settings["recurrence_pattern"], name, value)
|
||||
|
||||
ifcopenshell.util.sequence.is_working_day.cache_clear()
|
||||
ifcopenshell.util.sequence.is_calendar_applicable.cache_clear()
|
||||
|
||||
@@ -44,10 +44,11 @@ class Usecase:
|
||||
work_time = ifcopenshell.api.run("sequence.add_work_time", model,
|
||||
work_calendar=calendar, time_type="WorkingTimes")
|
||||
|
||||
# Edit our work time to state that the work time only applies after
|
||||
# a start date.
|
||||
# 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,
|
||||
work_time=work_time, attributes={"StartDate": "2000-01-01"})
|
||||
work_time=work_time, attributes={"StartDate": "2000-01-01", "FinishDate": "2000-01-02"})
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"work_time": work_time, "attributes": attributes or {}}
|
||||
|
||||
Reference in New Issue
Block a user