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.
 9
10# Create a local variable for the output toolbox
11ot = impact.gui.output_toolbox
12
13# Create a local variable for the database
14db = impact.active_database
15
16# Determine if a previous ProjectStartTime IGlobal object has been saved
17global_value = db.globals.item("ProjectStartTime")
18
19# Create a local variable for the drawing to work on
20drawing = db.auto_task_drawing
21
22# get the current impact.system time
23starttime = datetime.datetime.now()()
24
25# output a message about the project and start time
26ot.add("Project " + drawing.full_name + " now current (" + str(FormatDateTime(starttime, 3)) + ")")
27
28# add or update the IGlobal object to store the start time
29if global_value.isNone():
30    db.globals.add("ProjectStartTime", starttime)
31else:
32    global_value.value = starttime
33
34