Starting the application and logging in

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