diff --git a/src/bonsai/bonsai/bim/module/resource/operator.py b/src/bonsai/bonsai/bim/module/resource/operator.py index feff57030f..8ecef856e0 100644 --- a/src/bonsai/bonsai/bim/module/resource/operator.py +++ b/src/bonsai/bonsai/bim/module/resource/operator.py @@ -189,9 +189,13 @@ class CalculateResourceWork(bpy.types.Operator, tool.Ifc.Operator): @classmethod def poll(cls, context): active_resource = tool.Resource.get_highlighted_resource() - if active_resource: - if tool.Resource.get_productivity(active_resource, should_inherit=True): - return True + if not active_resource: + cls.poll_message_set("No resource is active.") + return False + if not tool.Resource.get_productivity(active_resource, should_inherit=True): + cls.poll_message_set("No productivity data for active resource.") + return False + return True def _execute(self, context): core.calculate_resource_work(tool.Ifc, tool.Resource, resource=tool.Ifc.get().by_id(self.resource)) @@ -415,12 +419,14 @@ class CalculateResourceUsage(bpy.types.Operator, tool.Ifc.Operator): @classmethod def poll(cls, context): active_resource = tool.Resource.get_highlighted_resource() - if active_resource: - if active_resource.Usage and active_resource.Usage.ScheduleWork: - task = tool.Resource.get_task_assignments(active_resource) - if task and tool.Sequence.has_duration(task): - return True - + if not active_resource: + cls.poll_message_set("No resource is active.") + return False + if active_resource.Usage and active_resource.Usage.ScheduleWork: + task = tool.Resource.get_task_assignments(active_resource) + if task and tool.Sequence.has_duration(task): + return True + cls.poll_message_set("No usage data for active resource.") return False def _execute(self, context):