mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
calculate resource usage/work - add poll messages
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user