Simple Update

Simple Update
 1db = impact.active_database
 2
 3impact.gui.output_toolbox.clear()
 4
 5drawing = db.create_item(ipDrawingType.dtProject, "")
 6
 7if not drawing.isNone():
 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            # We don't actually need to specify the Action because the project has
27            # been modified the Action is automatically set to ipReleaseAction.raUpdate
28            db_item.release_action.action = ipReleaseAction.raUpdate
29
30            if db_item.close_and_release():
31                impact.gui.output_toolbox.add("Successfully closed and released the project")
32            else:
33                impact.gui.output_toolbox.add("Error: Unable to release the project")
34
35        else:
36            impact.gui.output_toolbox.add("Error: Unable to save the project")
37
38    else:
39        impact.gui.output_toolbox.add("Error: Unable to save as the project")
40
41else:
42    impact.gui.output_toolbox.add("Error: Unable to create new project")
43
44
45
46
47
48
49
50
51