Starting the application and logging in

Starting the application and logging in
 1# This example is intended to be run from Windows, not
 2# from the impact Script Toolbox. It creates the impact
 3# object (which will start impact if it is not already
 4# running) and attempts to connect to a database.
 5# If the connection was successful a new drawing is created.
 6
 7# Create the impact object
 8# my_impact = CreateObject("impact.Application")
 9
10# ensure the impact object was created successfully
11if my_impact is not None:
12
13    # attempt to get a database
14    db = my_impact.databases.item("Test Database")
15
16    # ensure the database was obtained successfully
17    if not db.isNone():
18
19        # disconnect from the database
20        # db.disconnect()
21
22        # connect to the database
23        connected = db.connect("ALBERT", "MYPASSWORD")
24
25        # ensure the connection was successful
26        if connected:
27
28            # define a drawing type constant
29            ipDrawingType.dtProject = 0
30
31            # create a new drawing
32            my_impact.active_database.create_item(ipDrawingType.dtProject, "")
33        else:
34            impact.gui.output_toolbox.add("Unable to connect")
35    else:
36        impact.gui.output_toolbox.add("Unable to find specified database connection")
37else:
38    impact.gui.output_toolbox.add("Unable to communicate with impact")
39