calculate resource usage/work - add poll messages

This commit is contained in:
Andrej730
2024-11-14 14:12:28 +05:00
parent 6a20ecb2a0
commit a8d8600087
@@ -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):