Working Projects

Working Projects
 1# Create a local variable for the active database
 2
 3# Create a local variable for the active database
 4db = impact.active_database
 5
 6# Create a local variable for the output toolbox
 7ot = impact.gui.output_toolbox
 8
 9
10# Define a sub routine to describe an IDatabaseItem
11def describe_item(db_item):
12    if db_item is None:
13        return
14
15    ot.add("Code: " + str(db_item.code))
16    ot.add("Name: " + str(db_item.reference))
17    ot.add("description: " + str(db_item.description))
18    ot.add("Key: " + str(db_item.key))
19    ot.add("Type: " + str(db_item.drawing_type))
20    ot.add("customer: " + str(db_item.customer.name))
21    ot.add("folder: " + str(db_item.folder.display_path))
22
23    ot.add("*****")
24
25
26# Clear the output toolbox
27ot.clear()
28
29ot.add("**** Find By LoginID ****")
30
31# Create a local variable for the name of the user to find
32user_name = "CARL"
33
34# Find a user
35user = db.users.item(user_name)
36
37# Check the user was found
38if not user.isNone():
39
40    # Get the users working projects
41    items = user.get_working_projects()
42
43    if len(items) - 1 == 0:
44        ot.add("No Working Projects")
45    else:
46        ot.add("Working Project Count: " + str(len(items) - 1))
47
48        ot.add("*****")
49
50        # Iterate the working projects
51        for db_item in items:
52            describe_item(db_item)
53
54else:
55    ot.add("Error: Unable to locate the user '" + str(user_name) + "'")