Applying a saved visibility¶
Applying a saved visibility¶
1# This example finds a "Saved Visibility" master tool setting with a
2# specified name and applies it to the window of the active drawing
3
4# Create a local variable for the impact.gui
5g = impact.gui
6
7# Create a local variable for the output toolbox
8ot = g.output_toolbox
9
10# Clear the output toolbox
11ot.clear()
12
13# Create a local variable for the active drawing
14d = impact.active_drawing
15
16# Check that there is an active drawing
17if d.isNone():
18
19 # Add an error message to the output toolbox
20 ot.add("Unable to continue: there is no active drawing")
21
22else:
23
24 # Get all the "Saved Visibility" master tool settings
25 saved_visibility_settings = impact.active_database.find_master_tool_settings(ipMasterSettingType.mstSavedVisibility)
26
27 # Check that the settings were obtained successfully
28 if not saved_visibility_settings.isNone():
29
30 # Create a local variable for the name of the setting to apply
31 settings_name = "<Default>"
32
33 # Find the setting with the specified name
34 saved_visibility_setting = saved_visibility_settings.item(settings_name)
35
36 # Check the setting with the specified name was found
37 if not saved_visibility_setting.isNone():
38
39 # Apply the saved visibility
40 d.active_window.apply_saved_visibility(saved_visibility_setting)
41
42 else:
43
44 # Add an error message to the output toolbox
45 ot.add("Unable to find the setting '" + str(settings_name) + "'")
46
47 else:
48
49 # Add an error message to the output toolbox
50 ot.add("Unable to access the saved visibility settings")