SaveAs with Auto-Numbering¶
SaveAs with Auto-Numbering¶
1# this script demonstrates using Auto Numbering rules defined in the Database Installation settings
2# you should define rules for D_CODENUM and D_NAME for this script to work as expected
3# optionally you can define a rule for D_GROUP to specify a default save folder
4drawing = impact.active_drawing
5database = impact.active_database
6
7impact.gui.output_toolbox.clear()
8
9if not drawing.isNone():
10
11 # we can determine those columns that will be auto-generated
12 impact.gui.output_toolbox.add("AutoNumber Rules defined for the following columns in this drawing")
13 columns = drawing.auto_number_columns
14
15 for column in columns:
16 impact.gui.output_toolbox.add(column)
17
18 db_item = drawing.database_item
19
20 if db_item is None:
21
22 # we don't have to set the folder but useful to query and check its valid
23 folder = drawing.auto_number_save_folder
24
25 if folder is not None:
26 impact.gui.output_toolbox.add("AutoNumber Save folder: '" + str(folder.display_path) + "'")
27 else:
28 folder = database.projects.find("COMTests")
29
30 drawing.customer = database.customers.find_by_code("(DEFAULT)")
31
32 # save the new item - all values should be auto-generated
33 saved = drawing.save_as("", "", "", folder, False)
34
35 else:
36 saved = drawing.save()
37
38 if saved:
39 impact.gui.output_toolbox.add("Successfully saved '" + drawing.full_name + "'")
40 else:
41 impact.gui.output_toolbox.add("Unable to save " + str(drawing.full_name))
42
43
44