Global Mapper v26.0

ChatGPT

yianni
yianni Global Mapper UserTrusted User

Hi,


has anyone else tried to use chatgpt to write scripts?


I asked for a global mapper script that will take every loaded layer (line, dot, area) and export them individually into CAD files and name them accordingly.


I got the following:


// Global Mapper script to export loaded layers as individual DWG files

EXPORT_DIR = "C:\\Output\\DWG\\";

NUM_LAYERS = GM_LayerGetCount();


for (i = 0; i < NUM_LAYERS; i++) {

  LAYER_HANDLE = GM_GetLayerByIndex(i);

  LAYER_NAME = GM_GetName(LAYER_HANDLE);

  OUTPUT_FILE = EXPORT_DIR + LAYER_NAME + ".dwg";

  GM_ExportLayer(LAYER_HANDLE, OUTPUT_FILE, GM_ExportFormat.DWG, GM_ExportFlags.ExportedFile);

}


GM_Message("Export complete.");


----------------------------------------------

I also got the following when I asked again:


// Global Mapper script to export loaded layers as individual DWG files

// Define the output directory

EXPORT_DIR = "C:\\Output\\DWG\\";


// Get the number of loaded layers

NUM_LAYERS = GM_GetNumLoadedLayers();


// Loop through all the layers

for (i = 0; i < NUM_LAYERS; i++) {

  // Get the layer handle

  LAYER_HANDLE = GM_GetLayerByIndex(i);


  // Get the layer name

  LAYER_NAME = GM_GetName(LAYER_HANDLE);


  // Set the output file name

  OUTPUT_FILE = EXPORT_DIR + LAYER_NAME + ".dwg";


  // Export the layer as a DWG file

  GM_ExportLayer(LAYER_HANDLE, OUTPUT_FILE, GM_ExportFormat.DWG, GM_ExportFlags.ExportedFile, "");

}


// Notify user when script is finished

GM_Message("Export complete.");



neither work!


any thoughts, ideas? I think some of the above are not actual GM script commands. I have to say I am not familiar with scripts at all and I was hoping that chatgpt would be my way into this realm.


thanks

yianni

Tagged:

Comments