mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
New assign / unassign declaration usecase, minor code & formatting cleanup
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
from datetime import time
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {"recurrence_type": 'WEEKLY'}
|
||||
self.settings = {"parent": None, "recurrence_type": "WEEKLY"}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
|
||||
def execute(self):
|
||||
|
||||
recurrence = self.file.createIfcRecurrencePattern(self.settings['recurrence_type'])
|
||||
#recurrence.WeekdayComponent = [self.file.createIfcDayInWeekNumber(1),self.file.createIfcDayInWeekNumber(2)]
|
||||
recurrence.TimePeriods = [
|
||||
self.file.createIfcTimePeriod(time(8).isoformat(),time(12).isoformat()),
|
||||
self.file.createIfcTimePeriod(time(13).isoformat(),time(17).isoformat())
|
||||
]
|
||||
return recurrence
|
||||
recurrence = self.file.createIfcRecurrencePattern(self.settings["recurrence_type"])
|
||||
|
||||
if self.settings["parent"].is_a("IfcWorkTime") and self.settings["parent"].RecurrencePattern:
|
||||
if len(self.file.get_inverse(self.settings["parent"].RecurrencePattern)) == 1:
|
||||
self.file.remove(self.settings["parent"].RecurrencePattern)
|
||||
self.settings["parent"].RecurrencePattern = recurrence
|
||||
elif self.settings["parent"].is_a("IfcTaskTimeRecurring"):
|
||||
if len(self.file.get_inverse(self.settings["parent"].Recurrence)) == 1:
|
||||
self.file.remove(self.settings["parent"].Recurrence)
|
||||
self.settings["parent"].Recurrence = recurrence
|
||||
|
||||
Reference in New Issue
Block a user