Iterating Documents for Items

Iterating Documents for Items
 1ot = impact.gui.output_toolbox
 2db = impact.active_database
 3
 4
 5def describe_docs(desc, docs):
 6    if docs is None:
 7        ot.add(str(desc) + " not enabled in this database")
 8
 9    else:
10        ot.add(str(desc) + " Count: " + str(docs.count))
11
12
13ot.clear()
14
15
16# For this script the project needs to have multiple related documents, for example
17# documents for the customer, project, layers and site if possible
18
19proj_reference = "ACME12345"
20project = db.find_item_by_name(ipDrawingType.dtProject, proj_reference)
21
22if not project.isNone():
23
24    # Collections for direct relationships between the impact object and documents
25    describe_docs("Project Documents", project.documents)
26    describe_docs("customer Documents" , project.customer.documents)
27    describe_docs("Layer Documents", project.layers.item(1).documents)
28
29    # The AllDocuments collection contains all documents related to this project
30    # If documents have multiple relationships to the project they are only included
31    # once. For example if a document is related to both a project and a layer in that
32    # project, it is only included once.
33    describe_docs("All Documents", project.all_documents)
34
35else:
36    ot.add("Unable to find the project with code '" + str(proj_reference) + "'")
37