Creating Project Documents¶
Creating Project 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 docs = db_item.documents
11
12 if docs is None:
13 ot.add("No project document support in the database")
14 else:
15 ot.add("Project document support is enabled in this database")
16 ot.add(str(docs.count) + " documents for project '" + str(db_item.reference) + "' currently in the database")
17
18 doc = docs.add(r"C:\\Documents\\ExampleDocument1.docx", "My First Document")
19
20 if not doc.isNone():
21 ot.add("Document '" + doc.name + "' successfully created")
22
23 ot.add("Project: " + str(doc.database_item.reference))
24 ot.add("Added: " + str(doc.added_date_time) + " by " + str(doc.added_by.login_id))
25 ot.add("version: " + str(doc.version.version_as_string))
26 ot.add("Size: " + str(doc.size) + " bytes")
27
28 else:
29 ot.add("Unable to create new document")
30
31 # must reload IDocuments
32 docs = db_item.documents
33 ot.add(str(docs.count) + " documents for project '" + str(db_item.reference) + "' currently in the database")
34else:
35 ot.add("Unable to locate the project " + str(proj_reference))
36
37