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.8K All Categories
- 5.7K Features Discussion
- 345 Downloading Imagery
- 1.3K Elevation Data
- 385 Georeferencing Imagery Discussion
- 636 GM Script Language
- 54 User Scripts
- 114 GPS Features
- 417 Projection Questions
- 826 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 178 Announcement and News
- 913 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 569 Other Discussion
- 131 GIS Data Sources
- 27 Global Mapper Showcase
- 238 How I use Global Mapper
- 107 Global Mapper Forum Website