GeoTalks 2025 User Conference

Exporting to PNG not finding any loaded data.

Hi all,

This is my first time scripting in Global Mapper (using version 18) but I have been reading the scripting reference a lot. I thought I had this down but I still can't get a PNG to export at all.

I have about 12-18 layers in each workspace, most are vector data like outlines. I want to open up each workspace, select the correct layers, and export (either a DXF file or a PNG)

So I want in this example to only export all layers with the description that starts with "Outline". I've verified through logging that I'm hiding and unhiding the correct layers, but the export says that there is no loaded data. So I'm wondering if there is something I'm doing wrong in the EXPORT_RASTER command.

Code is below. Thanks for the help in advance,
Jake

GLOBAL_MAPPER_SCRIPT VERSION=1.0
// Clear out anything already loaded
UNLOAD_ALL

//Start loop
DIR_LOOP_START DIRECTORY="C:\Golf\Mapping\" FILENAME_MASKS="*.gmw" RECURSE_DIR=NO
    // Embed the script
    EMBED_SCRIPT FILENAME=%FNAME_W_DIR%

    LAYER_LOOP_START FILENAME="*"
        IF COMPARE_STR="%LAYER_DESC%=Outline*"
            // Unhide all layers that start with Outline
            SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=NO
        ELSE
            // Hide all other layers
            SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=YES
        END_IF
    LAYER_LOOP_END
   
    // Export PNG
    EXPORT_RASTER FILENAME="C:\Golf\MappingOutput\%FNAME_WO_EXT%_raster.png" TYPE="PNG"  \
    EXPORT_LAYER="*" FORCE_SQUARE_PIXELS=YES GEN_WORLD_FILE=YES GEN_PRJ_FILE=YES \
    BG_TRANSPARENT=YES INC_VECTOR_DATA=YES
   
    UNLOAD_ALL

DIR_LOOP_END
Tagged:

Comments

  • sportzfrk
    sportzfrk Banned User
    Update:

    The following script works if you check to run in the main view but will not work if it is unchecked. I really want to run this via command line, so without the main view would be ideal. Any idea why that's the case?

    Reminder that most of these layers are Embedded overlays in the workspace so they don't have file names associated with them, so I have to work with the layer descriptions. Is that why it can only work in the context of the main view?

    GLOBAL_MAPPER_SCRIPT VERSION=1.00
    DIR_LOOP_START DIRECTORY="C:\GolfX\Mapping\" FILENAME_MASKS="*.gmw" RECURSE_DIR=NO
        // Embed the script
        EMBED_SCRIPT FILENAME=%FNAME_W_DIR%
        // need to hide all layers
        LAYER_LOOP_START FILENAME="*"
            IF COMPARE_STR="%LAYER_DESC%=Outline*"
                // Unhide all layers that start with Outline
                SET_LAYER_OPTIONS FILENAME="%LAYER_DESC%" HIDDEN=NO
                LOG_MESSAGE This layer starts with Outline
            ELSE
                // Hide all other layers
                SET_LAYER_OPTIONS FILENAME="%LAYER_DESC%" HIDDEN=YES
                LOG_MESSAGE This layer did NOT start with Outline and was hidden.
            END_IF
        LAYER_LOOP_END
       
        // Export PNG
        EXPORT_RASTER FILENAME="C:\GolfX\MappingOutput\%FNAME_WO_EXT%_raster.png" \
        EXPORT_LAYER="*" TYPE="PNG" FORCE_SQUARE_PIXELS=YES GEN_WORLD_FILE=YES \
        GEN_PRJ_FILE=YES BG_TRANSPARENT=YES

    DIR_LOOP_END