Change customer¶
Change customer¶
1# This example finds a database item by it's code and changes the customer
2
3# Create a local variable for the output toolbox
4ot = impact.gui.output_toolbox
5
6# Clear the output toolbox
7ot.clear()
8
9# Declare a local variable to store the code of the database item to change
10database_item_code = "111479"
11
12# Find all the master tool settings
13database_item = impact.active_database.find_item_by_code(ipDrawingType.dtProject, database_item_code)
14
15# Check the settings were found
16if not database_item.isNone():
17
18 # Declare a local variable to store the code of the customer to change the database item to
19 customer_code = "WINTERBURY"
20
21 new_customer = impact.active_database.customers.find_by_code(customer_code)
22
23 if not new_customer.isNone():
24 if database_item.change_customer(new_customer, "Changed from script"):
25 ot.add("customer changed successfully")
26 else:
27 ot.add("Failed to change the customer")
28
29 else:
30 ot.add("Unable to find a customer with code " + str(customer_code))
31
32else:
33 ot.add("Unable to find a database item with code " + str(database_item_code))