Simple Release (Python)¶
Simple Release (Python)¶
1db = impact.active_database
2
3impact.gui.output_toolbox.clear()
4drawing = db.create_item(ipDrawingType.dtProject, "")
5
6if not drawing.isNone():
7
8 impact.gui.output_toolbox.add("Created new project")
9
10 drawing.customer = db.customers.find_by_code("(DEFAULT)")
11
12 impact.gui.output_toolbox.add("Finding folder r'\\COMTests'")
13 folder = None
14 try:
15 folder = db.projects.find("COMTests")
16 except Exception as exc:
17 pass
18 impact.gui.output_toolbox.add(f"Failed to create object via db.projects.find(): {exc}")
19
20 if drawing.save_as("", "COM Update Test", "", folder, True):
21
22 impact.gui.output_toolbox.add("Successfully saved project")
23 dbItem = drawing.database_item
24
25 # You can optionally call drawing.close but dbItem.close_and_release will
26 # automatically close the drawing if it is already open
27
28 # If the project has been modified CloseAndRelease will update the project
29 # otherwise it will discard the project.
30
31 if dbItem.close_and_release():
32 impact.gui.output_toolbox.add("Successfully closed and released the project")
33 else:
34 impact.gui.output_toolbox.add("Error: Unable to release the project")
35
36 else:
37 impact.gui.output_toolbox.add("Error: Unable to save the project")
38
39else:
40 impact.gui.output_toolbox.add("Error: Unable to create new project")