Simple Item Info

Simple Item Info
 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# Create a local variable for the folder name
10folder_name = "4. Examples"
11
12
13def describe_item(db_item):
14    if db_item is None:
15        return
16
17    ot.add("Code: " + str(db_item.code))
18    ot.add("Name: " + str(db_item.reference))
19    ot.add("description: " + str(db_item.description))
20    ot.add("Key: " + str(db_item.key))
21    ot.add("Type: " + str(db_item.drawing_type))
22    ot.add("customer: " + str(db_item.customer.name))
23    ot.add("folder: " + str(db_item.folder.display_path))
24    ot.add("Created: " + str(db_item.created_date_time))
25    ot.add("Created By: " + str(db_item.created_by.login_id))
26    ot.add("Modified: " + str(db_item.modified_date_time))
27    ot.add("Modified By: " + str(db_item.modified_by.login_id))
28    ot.add("Being Modified: " + str(db_item.being_modified))
29    ot.add("Master: " + str(db_item.master))
30    ot.add("version: " + str(db_item.version))
31
32    ot.add("*****")
33
34
35# Clear the output toolbox
36ot.clear()
37
38ot.add("**** Finding folder '" + str(folder_name) + "' ****")
39
40# Find the folder
41folder = db.projects.find(folder_name)
42
43# Check the folder was found
44if folder is not None:
45    ot.add("Item Count: " + str(folder.item_count))
46
47    # Iterate the items in the folder
48    for i in range(1, folder.items.count  + 1):
49        describe_item(folder.items.item(i))
50
51    # Alternative syntax
52    # for each db_item in folder.items
53    # DescribeItem db_item
54    # next
55else:
56    ot.add("Unable to find folder '" + str(folder_name) + "'")