Creating Layer Documents¶
Creating Layer 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 not db_item.isNone():
10 layer = db_item.layers.item(1)
11
12 docs = layer.documents
13
14 if docs is None:
15 ot.add("No project layer document support in the database")
16 else:
17 ot.add("Project layer document support is enabled in this database")
18 ot.add(str(docs.count) + " documents for project layer '" + layer.name + "' currently in the database")
19
20 doc = docs.add(r"C:\\Documents\\ExampleDocument1.docx", "My First Document")
21
22 if not doc.isNone():
23 ot.add("Document '" + doc.name + "' successfully created")
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 = layer.documents
33 ot.add(str(docs.count) + " documents for project layer '" + layer.name + "' currently in the database")
34else:
35 ot.add("Unable to locate the project " + str(proj_reference))
36
37
38