Simple Item Info (Python)¶
Simple Item Info (Python)¶
1# Create a local variable for the active database
2db = impact.active_database
3
4# Create a local variable for the output toolbox
5ot = impact.gui.output_toolbox
6
7def DescribeItem(dbItem):
8 if dbItem.isNone():
9 return
10
11 ot.add("Code: " + dbItem.code)
12 ot.add("Name: " + dbItem.reference)
13 ot.add("description: " + dbItem.description)
14 ot.add("Key: " + str(dbItem.key))
15 ot.add("Type: " + str(dbItem.drawing_type))
16 ot.add("customer: " + dbItem.customer.name)
17 ot.add("folder: " + dbItem.folder.display_path)
18 ot.add("Created: " + str(dbItem.created_date_time))
19 ot.add("Created By: " + dbItem.created_by.login_id)
20 ot.add("Modified: " + str(dbItem.modified_date_time))
21 ot.add("Modified By: " + dbItem.modified_by.login_id)
22 ot.add("Being Modified: " + str(dbItem.being_modified))
23 ot.add("Master: " + str(dbItem.master))
24 ot.add("version: " + str(dbItem.version))
25
26 ot.add("*****")
27
28# Clear the output toolbox
29ot.clear()
30
31# Create a local variable for the folder name
32folderName = "4. Examples"
33
34ot.add("**** Finding folder '" + folderName + "' ****")
35
36# Find the folder
37folder = None
38try:
39 folder = db.projects.find(folderName)
40except Exception as exc:
41 impact.gui.output_toolbox.add(f"Failed to create object via db.projects.find(): {exc}")
42
43# Check the folder was found
44if not folder.isNone():
45
46 ot.add("Item Count: " + str(folder.item_count))
47
48 # Iterate the items in the folder
49 for i in range(1, folder.items.count + 1):
50 DescribeItem(folder.items.item(i))
51 # Alternative syntax
52 # for each dbItem in folder.items
53 # DescribeItem dbItem
54 # next
55else:
56 ot.add("Unable to find folder '" + folderName + "'")