From 818e8010a4c7a485bb19cfde57b293c37000479e Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 25 Oct 2021 19:32:37 +1100 Subject: [PATCH] Minor fix. --- .../blenderbim/bim/module/pset/data.py | 3 +- .../bim/module/sequence/operator.py | 10 +++---- .../test/bim/feature/sequence.feature | 30 ++++++++++++++++++- .../api/sequence/add_work_plan.py | 6 ++-- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/pset/data.py b/src/blenderbim/blenderbim/bim/module/pset/data.py index bf190fd9c1..6e041bf29c 100644 --- a/src/blenderbim/blenderbim/bim/module/pset/data.py +++ b/src/blenderbim/blenderbim/bim/module/pset/data.py @@ -71,7 +71,8 @@ class ObjectPsetsData(Data): if element.is_a("IfcTypeObject"): return element_type = ifcopenshell.util.element.get_type(element) - return cls.psetqtos(element_type) + if element_type: + return cls.psetqtos(element_type) class ObjectQtosData(Data): diff --git a/src/blenderbim/blenderbim/bim/module/sequence/operator.py b/src/blenderbim/blenderbim/bim/module/sequence/operator.py index 3331d56782..1500bbbf65 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/operator.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/operator.py @@ -656,13 +656,13 @@ class CopyTaskAttribute(bpy.types.Operator): bl_idname = "bim.copy_task_attribute" bl_label = "Copy Task Attribute" bl_options = {"REGISTER", "UNDO"} - data: bpy.props.StringProperty() + name: bpy.props.StringProperty() def execute(self, context): return IfcStore.execute_ifc_operator(self, context) def _execute(self, context): - data = json.loads(self.data) + value = context.scene.BIMWorkScheduleProperties.task_attributes.get(self.name).get_value() self.file = IfcStore.get_file() props = context.scene.BIMTaskTreeProperties for task in props.tasks: @@ -670,10 +670,8 @@ class CopyTaskAttribute(bpy.types.Operator): ifcopenshell.api.run( "sequence.edit_task", self.file, - **{ - "task": self.file.by_id(task.ifc_definition_id), - "attributes": {data["name"]: None if data["is_null"] else data["value"]}, - }, + task=self.file.by_id(task.ifc_definition_id), + attributes={self.name: value}, ) Data.load(IfcStore.get_file()) bpy.ops.bim.load_task_properties() diff --git a/src/blenderbim/test/bim/feature/sequence.feature b/src/blenderbim/test/bim/feature/sequence.feature index 8c498c2dc5..5f1a2925d6 100644 --- a/src/blenderbim/test/bim/feature/sequence.feature +++ b/src/blenderbim/test/bim/feature/sequence.feature @@ -1,6 +1,34 @@ @sequence Feature: Sequence - Covers Visualising Work Schedule Date Range. + +Scenario: Add work plan + Given an empty IFC project + When I press "bim.add_work_plan" + Then nothing happens + +Scenario: Enable editing task + Given an empty IFC project + And I press "bim.add_work_schedule" + And the variable "work_schedule" is "IfcStore.get_file().by_type('IfcWorkSchedule')[0].id()" + And I press "bim.enable_editing_tasks(work_schedule={work_schedule})" + And I press "bim.add_summary_task(work_schedule={work_schedule})" + And the variable "task" is "IfcStore.get_file().by_type('IfcTask')[0].id()" + When I press "bim.enable_editing_task(task={task})" + Then nothing happens + +Scenario: Copy task attribute + Given an empty IFC project + And I press "bim.add_work_schedule" + And the variable "work_schedule" is "IfcStore.get_file().by_type('IfcWorkSchedule')[0].id()" + And I press "bim.enable_editing_tasks(work_schedule={work_schedule})" + And I press "bim.add_summary_task(work_schedule={work_schedule})" + And I press "bim.add_summary_task(work_schedule={work_schedule})" + And the variable "task" is "IfcStore.get_file().by_type('IfcTask')[0].id()" + And I press "bim.enable_editing_task(task={task})" + And I set "scene.BIMWorkScheduleProperties.task_attributes[2].string_value" to "Foo" + When I set "scene.BIMTaskTreeProperties.tasks[1].is_selected" to "True" + And I press "bim.copy_task_attribute(name='Description')" + Then nothing happens Scenario: See the current frame date as text Given an empty IFC project diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_plan.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_plan.py index c205f8f333..ab93d89685 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_plan.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_plan.py @@ -19,9 +19,9 @@ class Usecase: name=self.settings["name"], ) work_plan.CreationDate = ifcopenshell.util.date.datetime2ifc(datetime.now(), "IfcDateTime") - person = ifcopenshell.api.owner.settings.get_person(self.file) - if person: - work_plan.Creators = [person] + user = ifcopenshell.api.owner.settings.get_user(self.file) + if user: + work_plan.Creators = [user.ThePerson] work_plan.StartTime = ifcopenshell.util.date.datetime2ifc(self.settings["start_time"], "IfcDateTime") context = self.file.by_type("IfcContext")[0]