RunScript¶
- globalmapper.RunScript(str aFilenameOrText, GM_LoadFlags_t32 aLoadFlags, uint32 aReserved=0) GM_Error_t32, GM_LayerHandle_t32, uint32 [source]¶
Runs a Global Mapper script (.gms) or workspace (.gmw). You can provide the filename of the script to run or you can provide script as raw text. Any layers loaded by the script will be returned as a pointer to an array of Layer Handles, and a uint32 will also be returned to specify the length of the array. Both will be 0 if no layers were loaded or created. Refer to the tutorial page on working with layer handles for more information on how to turn the array pointer into a usable object in Python.
Almost all of the functionalities in Global Mapper that don’t have a corresponding function call in the SDK can be accessed using RunScript. The complete list of scripts that can be performed by this function can be found here: https://www.bluemarblegeo.com/knowledgebase/global-mapper-23-1/Scripting_Reference/Global_Mapper_Scripting_Language.htm
- Parameters:
aFilenameOrText (str) – str with full path of script or the actual text of the script
aLoadFlags (GM_LoadFlags_t32) – Extra flags for load behavior
aReserved (uint32) – Reserved for future use; defaults to 0
- Returns:
Error Code
- Return type:
GM_Error_t32
- Returns:
Pointer to array of layer handles loaded by the script
- Return type:
GM_LayerHandle_t32
- Returns:
Number of layer handles in the array
- Return type:
uint32
Example¶
The following is an example of RunScript.:
# setup grid parameters
gridsetup_string = "GENERATE_ELEV_GRID "
gridsetup_string += "FILENAME=" + str(filepath) + " " # use the file path, not the layer handle
gridsetup_string += "LAYER_DESC=ElevationGrid "
gridsetup_string += "SPATIAL_RES=1.0,1.0 "
gridsetup_string += "ELEV_UNITS=METERS "
gridsetup_string += "GRID_ALG=BIN_MAX "
gridsetup_string += "GRID_TYPE=ELEVATION "
gridsetup_string += "GRIDBINSIZE=2 "
gridsetup_string += "LIDAR_FILTER=\"NONE,2\""
err_code, elev_addr, num = gm.RunScript(gridsetup_string, gm.GM_LoadFlags_UseDefaultLoadOpts, 0)
For a more context refer to the tutorial page on working with RunScript.