Document Used in Images

Document Used in Images
 1# this example shows how to determine if a document is being used in any graphic
 2# images within a project. For a customer document you can determine which projects
 3# the document is being used in.
 4
 5ot = impact.gui.output_toolbox
 6db = impact.active_database
 7
 8ot.clear()
 9
10cust = db.customers.find_by_code("ACME CORP")
11
12if cust is not None:
13    docs = cust.documents
14
15    if docs is None:
16        ot.add("No customer document support in the database")
17    else:
18        ot.add("Locating document by name")
19
20        doc = docs.item("akpack_01.gif")
21
22        if not doc.isNone():
23            ot.add("Located Document: '" + doc.name + "', impact.creator: " + str(doc.added_by.login_id) + ", Size: " + str(doc.size) + " bytes")
24
25            if doc.used_in_image:
26                ot.add("Document is being used in one or more graphic images")
27
28                # for a customer document you can also retrieve all the projects its in
29                projects = doc.used_in_projects
30
31                for k in range(0, len(projects) - 1  + 1):
32                    ot.add("  Project " + str(k) + ": " + str(projects[k].reference))
33
34            else:
35                ot.add("Document is not being used in any graphic images")
36
37        else:
38            ot.add("Unable to locate document")
39else:
40    ot.add("Unable to locate a customer")
41
42