Active Layer Change (After) Auto-Task¶
Active Layer Change (After) Auto-Task¶
1# This example shows how to use the Active Layer Change (After) automation task to automate the time
2# spent by a designer working on a layer. 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 and IDatabase.auto_task_layer rather than
6# IDrawings.active_drawing or IDrawing.active_layer
7#
8# You should see the Active Layer Change (Before) example to see how it processes the actual time
9# spent on the Layer.
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 LayerStartTime IGlobal object has been saved
18global_value = db.globals.item("LayerStartTime")
19
20# Create a local variable for the drawing and layer to work on
21drawing = db.auto_task_drawing
22layer = db.auto_task_layer
23
24# get the current impact.system time
25starttime = datetime.datetime.now()()
26
27# output a message about the layer and start time
28ot.add("Layer " + layer.full_name + " of Project " + drawing.full_name + " now current (" + str(FormatDateTime(starttime, 3)) + ")")
29
30# add or update the IGlobal object to store the start time
31if global_value.isNone():
32 db.globals.add("LayerStartTime", starttime)
33else:
34 global_value.value = starttime
35
36