maptek.vulcan_gui

Provides an interface to the Vulcan Graphical User Interface functionality.

To download all the example scripts, click here.


Note

To use any of the method calls from this class, be sure to import the library at the top of your Python script, like this:

from maptek import vulcan_gui

Special dialog panels

message start_busy_message
error end_busy_message
confirm  
maptek.vulcan_gui.message(msg)

Displays a message box.

# Filename: gui_messagebox.py
# Purpose: Displays a message box.

from maptek import vulcan_gui

vulcan_gui.message('This is a message box.')

maptek.vulcan_gui.error(msg)

Displays an error message in Vulcan.

# Filename: gui_error_message.py
# Purpose: Displays an error message.

from maptek import vulcan_gui, vulcan

vulcan_gui.error('This is an error message.')

maptek.vulcan_gui.confirm(msg, ok (first choice), cancel (second choice))→ bool

Displays a confirmation prompt. Returns True for first choice; False for second choice.

To provide padding on either side on the prompt title, add a space at the beginning and ending of the text. For example,

Parameters

  • msg (str (default = 'Confirm')) – Message to display to the user.

  • ok (str (default = 'Ok')) – First choice option.

  • cancel (str (default = 'Cancel')) – Second choice option.

# Filename: gui_confirm.py
# Purpose: Displays a confirmation prompt. 
# Returns: OK = first choice; Cancel = second choice.

from maptek import vulcan_gui, vulcan

vulcan_gui.confirm(' Delete layer? ')

maptek.vulcan_gui.start_busy_message(msg, time=-1)
maptek.vulcan_gui.end_busy_message()

Start and stop a busy message (small non-interactive message). Use this to notify users that there are processes running in the background even though there may seem to be nothing happening.

Parameters for start message

  • msg (message)

  • time (int) in milliseconds. This is the time delay before the message will be displayed. A time of -1 will display message immediately.

# Filename: gui_start_busy_msg.py
# Starts a busy message (small non-interactive message).

from maptek import vulcan_gui, vulcan
from time import sleep

vulcan_gui.start_busy_message('Processing your data...', 3000)
sleep(8) # add a few seconds to read message.
vulcan_gui.end_busy_message()

Handling objects

maptek.vulcan_gui.globals()→ MVariant

Access to current data items in Vulcan and returns a dictionary.

# Filename: gui_globals.py
# Purpose: Access current data items in Vulcan.
# Returns: Dictionary.

from maptek import vulcan_gui

current_data = vulcan_gui.globals()
for key, value in current_data.items():
    print(f'{key} : {value}')
maptek.vulcan_gui.save()

Issues a save command to Vulcan when working with interactive code.

# Filename: gui_save.py
# Purpose: Issues a save command to Vulcan when working with interactive code.

from maptek import vulcan_gui

sel = vulcan_gui.selection("Select object to change colour")

for obj in sel:
    obj.colour += 1
    sel.replace(obj)
vulcan_gui.save()
maptek.vulcan_gui.get_main_window_handle()→ unsigned int

Get the main window handle of the Workbench

# Filename: gui_get_main_window_handle.py
# Purpose: Get the main window handle of the Workbench.

from maptek import vulcan_gui

unsigned_int = vulcan_gui.get_main_window_handle()

print(unsigned_int)
maptek.vulcan_gui.get_current_dgd_attribute_templates()→ MVariant

Gets the attribute templates from the currently opened design database.

# Filename: gui_get_current_dgd_attribute_templates.py
# Gets the attribute templates from the currently opened design database.
# Returns: Dictionary.

from maptek import vulcan_gui

dict = vulcan_gui.get_current_dgd_attribute_templates()
for key, value in dict.items():
    print(f'{key} : {value}')
maptek.vulcan_gui.get_resource_attribute_templates()→ MVariant

Gets the attribute templates from the resource template file.

# Filename: gui_get_resource_attribute_templates.py
# Gets the attribute templates from the resource template file.
# Returns: Dictionary.

from maptek import vulcan_gui

dict = vulcan_gui.get_resource_attribute_templates()
for key, value in dict.items():
    print(f'{key} : {value}')
maptek.vulcan_gui.pick_triangulation(prompt)→ std::string

Prompt informing users to pick a triangulation that has been loaded onto the screen.

  • If no triangulations are loaded, then a warning is issued.

  • If only one triangulation is loaded, then a confirmation is displayed asking if the only loaded triangulation is the correct one.

  • If more than one triangulation is loaded, then the user can select the correct one by clicking on it.

# Filename: gui_pick_triangulation.py
# Purpose: Prompt users to pick a triangulation loaded onto the screen.
# Returns: String.

from maptek import vulcan_gui

selected_tri = vulcan_gui.pick_triangulation('Pick a triangulation')
maptek.vulcan_gui.get_layer(layerName)→ layer

Loads a layer from Vulcan by name.

# Filename: gui_get_layer.py
# Purpose: Loads a layer by name.
# Returns: Layer object.

from maptek import vulcan_gui

# isolated method call will load layer
vulcan_gui.get_layer('MY_LAYER')

# By default, if a layer does not exist no warning will be issued.
# The following code provides a message to the user if a layer does not exist.
if not vulcan_gui.get_layer('MY_LAYER'):
    vulcan_gui.error('Layer does not exist.')
maptek.vulcan_gui.add_layer(lyr, loadMethod='LOAD_IF_EXISTS')→ bool

Adds a layer to the active design database (dgd).

Parameters

  • lyr (layer object)

  • loadMethod (option) Note: This argument is optional.

    loadMethod options include:

    1. LOAD_IF_EXISTS - If a layer already exists, it will be loaded onto the screen and any additional objects will be added to the layer.

    2. CLEAR_IF_EXISTS - New object(s) will overwrite existing layer.

    3. PROMPT_IF_EXISTS - If a layer already exists, a prompt will be displayed requiring a user response.

    4. PROMPT_IF_NOT_LOADED - If a layer already exists, a prompt will be displayed requiring a user response.

    5. ACTIVE_IF_EXISTS - Overwrites existing layer with new object(s) and loads onto the screen.

    6. ACTIVE_PROMPT_IF_NOT_SET - Displays the Allocate Layer panel allowing the user to enter a name for the new layer, replacing the name provided in the script.

    7. This provides two layer naming scenarios: a name defined in the script or a name defined using the panel.

      • If an existing layer with the same name is not loaded, then the new layer object(s) will overwrite the existing layer.

      • If an existing layer with the same name is loaded, then the new layer object(s) will be added to the existing layer.

      • Entering a new name for the layer into the panel, then clicking OK, will create a new layer and leave the existing layer as is.

      • Clicking Cancel will close the panel and allow the script to continue as written, overwriting any existing layers with the same name.

    8. PROMPT_NEW_ACTIVE

      • If an existing layer with the same name is not loaded, then the new layer object(s) will overwrite the existing layer.

      • If an existing layer with the same name is loaded, then the new layer object(s) will be added to the existing layer.

      • Entering a new name for the layer into the panel, then clicking OK, will create a new layer and leave the existing layer as is.

      • Clicking Cancel will close the panel and exit the script.

# Filename: gui_add_layer.py
# Purpose: Adds a layer to the active dgd.
# Returns: Bool.

from maptek import vulcan_gui, vulcan

layer = vulcan.layer('NEW_POINT')
new_pt = vulcan.polyline([[76500.0, 4500.0, 0.0]])
layer.append(new_pt)
vulcan_gui.add_layer(layer, 'CLEAR_IF_EXISTS')
vulcan_gui.save()
maptek.vulcan_gui.load_triangulation(file, interactive=False)→ bool

Load triangulation into Vulcan.

Note

If interactive=False, then the triangulation will load directly.

If interactive=True, then the triangulation Properties panel will be displayed before the triangulation loads.

Parameters

  • file (string) - Name of triangulation

  • interactive (bool)

# Filename: gui_load_triangulation.py
# Purpose: Load a triangulation into Vulcan.
# Returns: Bool.

from maptek import vulcan_gui

# if interactive = False, then triangulation loads directly.
# if interactive = True, then triangulation Properties panel displays first.
vulcan_gui.load_triangulation('Pit_Solid.00t', interactive=True)
maptek.vulcan_gui.load_triangulations(files)→ bool

Load a list of triangulations into Vulcan.

Parameters

  • files (list)

# Filename: gui_load_triangulations.py
# Purpose: Load a list of triangulations into Vulcan.
# Returns: Bool.

from maptek import vulcan_gui

tri_list = ['Pit_Solid.00t', 'oreshape.00t']

vulcan_gui.load_triangulations(tri_list)
maptek.vulcan_gui.reload_triangulation(file)

Reloads a triangulation in Vulcan after first displaying the triangulation Properties panel.

Note:  This is useful if you make edits in the Properties panel and need to reload the triangulation to see the changes.

Parameters

  • file (name of triangulation)

# Filename: gui_reload_triangulation.py
# Purpose: Reloads a triangulation after first displaying the Properties panel.
# Returns: Bool.

from maptek import vulcan_gui

vulcan_gui.reload_triangulation('Pit_Solid.00t')
maptek.vulcan_gui.remove_layers(layer_names)→ bool

Parameters

  • layer_names (list)

# Filename: gui_remove_layers.py
# Purpose: Removes a list of layers from Vulcan.
# Returns: Bool.

from maptek import vulcan_gui

layer_list = ['CENTROID_OF_TOPO', 'POINT_GRID']

vulcan_gui.remove_layers(layer_list)
maptek.vulcan_gui.remove_triangulations(files)→ bool

Remove a list of triangulations from Vulcan. If any triangulations fail (not loaded or had unsaved data), it will raise a RuntimeError indicating which item(s) failed.

Parameters

  • files (list)

# Filename: gui_remove_triangulations.py
# Purpose: Removes a list of triangulations from Vulcan.
# Returns: Bool.

from maptek import vulcan_gui

tri_list = ['Pit_Solid.00t', 'oreshape.00t']

vulcan_gui.remove_triangulations(tri_list)
maptek.vulcan_gui.set_object_visibility(object, mode)→ bool

Sets the visibility of an object in Vulcan. Only supports objects from the GUI with the visibility modes of VISIBLE, SHADOW, and INVISIBLE.

Parameters

  • object (obj)

  • mode ('VISIBLE', 'SHADOW', or 'INVISIBLE')

# Filename: gui_set_object_visibility.py
# Purpose: Set the visibility of an object in Vulcan.
# Returns: Bool.

from maptek import vulcan_gui

sel = vulcan_gui.selection('Select object')

for obj in sel:
    vulcan_gui.set_object_visibility(obj, 'SHADOW')

maptek.vulcan_gui.get_object_visibility(object)→ std::string

Gets the visibility state of an object in Vulcan.

# Filename: gui_get_object_visibility.py
# Purpose: Get the visibility state of an object in Vulcan.
# Returns: Bool.

from maptek import vulcan_gui

sel = vulcan_gui.selection('Select object')

for obj in sel:
    vis = vulcan_gui.get_object_visibility(obj)

    # do something with result...
    print(vis)
get_values(self)→ MVariant

Gets the values from the panel (after it has run) and saves them to a dictionary.

# Filename: gui_get_values.py
# Purpose: Gets values from a panel (after it has run) and save to dictionary.
# Returns: Dictionary.

from maptek import vulcan_gui

pan = vulcan_gui.panel("Basic Panel")
pan.checkbox(tag='checkbox_1', prompt='Checkbox one', checked=False)
pan.checkbox(tag='checkbox_2', prompt='Checkbox two', checked=False)
pan.checkbox(tag='checkbox_3', prompt='Checkbox three', checked=False)
pan.display()

dict = pan.get_values()
print(dict)
set_values(self, values)

Preloads panel key values with input dictionary values.

Parameters

  • values (dictionary)

# Filename: gui_set_values.py
# Purpose: Preloads panel key values with input dictionary values.
# Returns: Void.

from maptek import vulcan_gui

pan = vulcan_gui.panel("Basic Panel")
pan.checkbox(tag='checkbox_1', prompt='Checkbox one', checked=False)
pan.checkbox(tag='checkbox_2', prompt='Checkbox two', checked=False)
pan.checkbox(tag='checkbox_3', prompt='Checkbox three', checked=False)

pan.set_values({'checkbox_2': 1, 
                'checkbox_3': 0, 
                'checkbox_1': 0
              })

pan.display()
save_spec(self, specName)

Saves the panel data to a specification file.

Note:  This method call needs to be placed after the display() method call.

Parameters

  • specName (string) - Name of specification file including extension.

    'settings.spec'

# Filename: gui_save_spec.py
# Purpose: Saves the panel data to a specification file.
# Returns: Void.

from maptek import vulcan_gui

pan = vulcan_gui.panel("Basic Panel")
pan.checkbox(tag='checkbox_1', prompt='Checkbox one', checked=False)
pan.checkbox(tag='checkbox_2', prompt='Checkbox two', checked=False)
pan.checkbox(tag='checkbox_3', prompt='Checkbox three', checked=False)
pan.display()

pan.save_spec('settings.spec')
load_spec(self, specName)

Loads a specification file into the panel.

Note:  This method call needs to be placed before the display() method call.

Parameters

  • specName (std::string const &)

# Filename: gui_load_spec.py
# Purpose: Loads a specification file into the panel.
# Returns: Void.

from maptek import vulcan_gui

pan = vulcan_gui.panel("Basic Panel")
pan.checkbox(tag='checkbox_1', prompt='Checkbox one', checked=False)
pan.checkbox(tag='checkbox_2', prompt='Checkbox two', checked=False)
pan.checkbox(tag='checkbox_3', prompt='Checkbox three', checked=False)

pan.load_spec('settings.spec')
pan.display()