Performing a value mapping¶
Performing a value mapping¶
1# This example performs a value mapping on the active layer of the active
2# drawing
3
4# Create a local variable for the output toolbox
5ot = impact.gui.output_toolbox
6
7# Clear the output toolbox
8ot.clear()
9
10# Create a local variable for the active drawing
11ad = impact.active_drawing
12
13# Check there is an active drawing
14if ad.isNone():
15
16 # Display an error message in the output toolbox
17 ot.add("Unable to continue: there must be an active drawing")
18else:
19
20 # Check the active layer is a one up layer
21 if not ad.active_layer.layer_type == "ONE_UP":
22
23 # Display an error message in the output toolbox
24 ot.add("Unable to continue: the active layer must be a one up layer")
25 else:
26
27 # Create a local variable for the setting name (i.e. the value mapping to
28 # be performed)
29 setting_name = "One Up Mapping"
30
31 # Attempt to find the specified value mapping master tool setting
32 setting = impact.active_database.find_master_tool_setting(setting_name, ipMasterSettingType.mstDBValueMapping)
33
34 # Check the setting exists
35 if not setting.isNone():
36
37 # Perform the value mapping
38 impact.gui.perform_value_mapping2(setting, ad, ad.active_layer)
39 else:
40
41 # Display an error message in the output toolbox
42 ot.add("Unable to continue: the value mapping '" + str(setting_name) + "' does not exist")