Active Drawing Change (After) Auto-Task¶
Active Drawing Change (After) Auto-Task¶
1# This example shows how to use the Active Drawing Change (After) automation task to automate the time
2# spent by a designer working on a project. It uses an IGlobal session variable to store
3# the start time, but you could use any mechanism you like such as a file or a database record.
4#
5# It is important to use the IDatabase.auto_task_drawing rather than IDrawings.active_drawing
6#
7# You should see the Active Drawing Change (Before) example to see how it processes the actual time
8# spent on the Project.
9import datetime
10
11# Create a local variable for the output toolbox
12ot = impact.gui.output_toolbox
13
14# Create a local variable for the database
15db = impact.active_database
16
17# Determine if a previous ProjectStartTime IGlobal object has been saved
18global_value = db.globals.item("ProjectStartTime")
19
20# Create a local variable for the drawing to work on
21drawing = db.auto_task_drawing
22
23# get the current impact.system time
24starttime = datetime.datetime.now()
25
26# output a message about the project and start time
27ot.add("Project " + drawing.full_name + " now current (" + str(starttime.isoformat()) + ")")
28
29# add or update the IGlobal object to store the start time
30if global_value.isNone():
31 db.globals.add("ProjectStartTime", starttime)
32else:
33 global_value.value = starttime
34