Simple Discard¶
Simple Discard¶
1db = impact.active_database
2
3impact.gui.output_toolbox.clear()
4
5drawing = db.create_item(ipDrawingType.dtProject, "")
6
7if drawing is not None:
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 = db.projects.find("COMTests")
14
15 if drawing.save_as("", "COM Update Test", "", folder, True):
16 impact.gui.output_toolbox.add("Successfully saved project")
17
18 db_item = drawing.database_item
19
20 # Modify and save the drawing
21 drawing.active_layer.active_block.moved(0, 0)
22 drawing.active_layer.active_block.line_ad(100, 100)
23
24 if drawing.save():
25
26 # Force a discard even if the project has been modified
27 db_item.release_action.action = ipReleaseAction.raDiscard
28
29 if db_item.close_and_release():
30 impact.gui.output_toolbox.add("Successfully closed and released the project")
31 else:
32 impact.gui.output_toolbox.add("Error: Unable to release the project")
33
34 else:
35 impact.gui.output_toolbox.add("Error: Unable to save the project")
36
37 else:
38 impact.gui.output_toolbox.add("Error: Unable to save as the project")
39
40else:
41 impact.gui.output_toolbox.add("Error: Unable to create new project")
42
43
44
45
46
47
48
49