Saving Projects¶
Saving Projects¶
1drawing = impact.active_drawing
2database = impact.active_database
3
4if not drawing.isNone():
5
6 # This script only works for projects, but it could easily be adapted
7 # by simply ensuring that the IFolder was valid for the drawing.drawing_type
8 if drawing.drawing_type == ipDrawingType.dtProject:
9 db_item = drawing.database_item
10
11 if db_item is None:
12 folder = database.projects.find("COMTests")
13
14 drawing.customer = database.customers.find_by_code("(DEFAULT)")
15
16 # Save the new project, we don't supply a Code we want it automatically
17 # generated, plus not supplying a description will use the existing one
18 saved = drawing.save_as("", "DB Save Test 1", "", folder, False)
19
20 else:
21 saved = drawing.save()
22
23 if saved:
24 impact.gui.output_toolbox.add("Successfully saved '" + drawing.full_name + "'")
25 else:
26 impact.gui.output_toolbox.add("Unable to save " + str(drawing.full_name))
27
28 else:
29 impact.gui.output_toolbox.add("Current drawing is not a project")
30
31
32