Displaying ‘Add Documents’

Displaying ‘Add Documents’
 1ot = impact.gui.output_toolbox
 2db = impact.active_database
 3
 4ot.clear()
 5
 6proj_reference = "ACME12345"
 7db_item = db.find_item_by_name(ipDrawingType.dtProject, proj_reference)
 8
 9if db_item is not None:
10
11    # using IDatabaseItem.documents ensures a relationship to the item is added by default
12    docs = db_item.documents
13
14    if docs is None:
15        ot.add("No project document support in the database")
16    else:
17        ot.add("Project document support is enabled in this database")
18
19        # simplest operation with IDocumentCreator is to show the 'Add Documents' dialog
20        # to the user and then create the documents the user added
21        doc_creator = docs.creator
22
23        if doc_creator.show_dialog():
24            if doc_creator.perform():
25                ot.add("Successfully added documents")
26            else:
27                ot.add("No documents added")
28        else:
29            ot.add("Cancelled by user")
30else:
31    ot.add("Unable to locate the project " + str(proj_reference))
32
33