ChatGPT

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
Comments
-
Hi yianni,
Looks like chatgpt is giving you code that uses the Global Mapper SDK, probably the "C" language version, rather than GMS scripting language. I've never used chatgpt before, so I don't know how to get it to generate GM scripting language scripts.
I'd suggest looking at the Global Mapper online scripting references. The Quick Reference is here: https://www.bluemarblegeo.com/knowledgebase/global-mapper-24-1/Scripting_Reference/Global_Mapper_Scripting_Language.htm.
If you have problems, feel free to ask here in the forums.
Best regards,
~Jeff
Categories
- 12.5K All Categories
- 5.5K Features Discussion
- 314 Downloading Imagery
- 1.3K Elevation Data
- 377 Georeferencing Imagery Discussion
- 611 GM Script Language
- 50 User Scripts
- 112 GPS Features
- 397 Projection Questions
- 805 Raster Data
- 1.3K Vector Data
- 6.5K Support
- 161 Announcement and News
- 893 Bug Report
- 557 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 546 Other Discussion
- 128 GIS Data Sources
- 26 Global Mapper Showcase
- 230 How I use Global Mapper
- 104 Global Mapper Forum Website