mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix issues editing work time in ifc4x3 #4295
This commit is contained in:
@@ -55,8 +55,8 @@ class Usecase:
|
||||
|
||||
def execute(self):
|
||||
for name, value in self.settings["attributes"].items():
|
||||
if value and name in ["Start", "Finish"]:
|
||||
if value and name in ("Start", "Finish", "StartDate", "FinishDate"):
|
||||
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDate")
|
||||
if self.file.schema == "IFC4X3":
|
||||
if self.file.schema == "IFC4X3" and name in ("Start", "Finish"):
|
||||
name += "Date"
|
||||
setattr(self.settings["work_time"], name, value)
|
||||
|
||||
@@ -19,5 +19,9 @@
|
||||
},
|
||||
"IfcComplexProperty": {
|
||||
"Specification": "Description"
|
||||
},
|
||||
"IfcWorkTime": {
|
||||
"StartDate": "Start",
|
||||
"FinishDate": "Finish"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
# IfcOpenShell - IFC toolkit and geometry engine
|
||||
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of IfcOpenShell.
|
||||
#
|
||||
# IfcOpenShell is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# IfcOpenShell is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# 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 datetime
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestEditWorkTime(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
work_time = self.file.createIfcWorkTime()
|
||||
recurrence_pattern = self.file.createIfcRecurrencePattern()
|
||||
attributes = {
|
||||
"Name": "Test",
|
||||
"DataOrigin": "USERDEFINED",
|
||||
"UserDefinedDataOrigin": "Custom",
|
||||
"RecurrencePattern": recurrence_pattern,
|
||||
"Start": datetime.datetime(2020, 1, 1),
|
||||
"Finish": datetime.datetime(2020, 2, 1),
|
||||
}
|
||||
ifcopenshell.api.run("sequence.edit_work_time", self.file, work_time=work_time, attributes=attributes)
|
||||
assert work_time.Name == attributes["Name"]
|
||||
assert work_time.DataOrigin == attributes["DataOrigin"]
|
||||
assert work_time.UserDefinedDataOrigin == attributes["UserDefinedDataOrigin"]
|
||||
assert work_time.RecurrencePattern == attributes["RecurrencePattern"]
|
||||
assert work_time.Start == "2020-01-01"
|
||||
assert work_time.Finish == "2020-02-01"
|
||||
|
||||
|
||||
class TestEditWorkTimeIFC4X3(test.bootstrap.IFC4X3):
|
||||
def test_run(self):
|
||||
work_time = self.file.createIfcWorkTime()
|
||||
recurrence_pattern = self.file.createIfcRecurrencePattern()
|
||||
attributes = {
|
||||
"Name": "Test",
|
||||
"DataOrigin": "USERDEFINED",
|
||||
"UserDefinedDataOrigin": "Custom",
|
||||
"RecurrencePattern": recurrence_pattern,
|
||||
"StartDate": datetime.datetime(2020, 1, 1),
|
||||
"FinishDate": datetime.datetime(2020, 2, 1),
|
||||
}
|
||||
ifcopenshell.api.run("sequence.edit_work_time", self.file, work_time=work_time, attributes=attributes)
|
||||
assert work_time.Name == attributes["Name"]
|
||||
assert work_time.DataOrigin == attributes["DataOrigin"]
|
||||
assert work_time.UserDefinedDataOrigin == attributes["UserDefinedDataOrigin"]
|
||||
assert work_time.RecurrencePattern == attributes["RecurrencePattern"]
|
||||
assert work_time.StartDate == "2020-01-01"
|
||||
assert work_time.FinishDate == "2020-02-01"
|
||||
|
||||
def test_ifc4_code_to_work_in_ifc4x3(self):
|
||||
work_time = self.file.createIfcWorkTime()
|
||||
recurrence_pattern = self.file.createIfcRecurrencePattern()
|
||||
attributes = {
|
||||
"Name": "Test",
|
||||
"DataOrigin": "USERDEFINED",
|
||||
"UserDefinedDataOrigin": "Custom",
|
||||
"RecurrencePattern": recurrence_pattern,
|
||||
"Start": datetime.datetime(2020, 1, 1),
|
||||
"Finish": datetime.datetime(2020, 2, 1),
|
||||
}
|
||||
ifcopenshell.api.run("sequence.edit_work_time", self.file, work_time=work_time, attributes=attributes)
|
||||
assert work_time.Name == attributes["Name"]
|
||||
assert work_time.DataOrigin == attributes["DataOrigin"]
|
||||
assert work_time.UserDefinedDataOrigin == attributes["UserDefinedDataOrigin"]
|
||||
assert work_time.RecurrencePattern == attributes["RecurrencePattern"]
|
||||
assert work_time.StartDate == "2020-01-01"
|
||||
assert work_time.FinishDate == "2020-02-01"
|
||||
Reference in New Issue
Block a user