mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36: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
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
active_resource = tool.Resource.get_highlighted_resource()
|
active_resource = tool.Resource.get_highlighted_resource()
|
||||||
if active_resource:
|
if not active_resource:
|
||||||
if tool.Resource.get_productivity(active_resource, should_inherit=True):
|
cls.poll_message_set("No resource is active.")
|
||||||
return True
|
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):
|
def _execute(self, context):
|
||||||
core.calculate_resource_work(tool.Ifc, tool.Resource, resource=tool.Ifc.get().by_id(self.resource))
|
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
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
active_resource = tool.Resource.get_highlighted_resource()
|
active_resource = tool.Resource.get_highlighted_resource()
|
||||||
if active_resource:
|
if not active_resource:
|
||||||
if active_resource.Usage and active_resource.Usage.ScheduleWork:
|
cls.poll_message_set("No resource is active.")
|
||||||
task = tool.Resource.get_task_assignments(active_resource)
|
return False
|
||||||
if task and tool.Sequence.has_duration(task):
|
if active_resource.Usage and active_resource.Usage.ScheduleWork:
|
||||||
return True
|
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
|
return False
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
|
|||||||
Reference in New Issue
Block a user