KB no longer maintained - MapViewer is a Legacy Product. Legacy Products are still supported, but no longer receive new features or updates. Many of MapViewer's features have been moved to Surfer. Please contact support@goldensoftware.com with any questions. |
This article contains a sample script for swapping the PID and SID for all objects in all base maps of GSM files in a given directory.
To run this script:
- Copy the script below, or click here to download the BAS file: RedefineAttribs.BAS.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\MapViewer 8\Scripter.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
- Click Script | Run to run the script.
*********
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' RedefineAttribs.BAS ' Copyright (C) Golden Software Inc. 1992-2015 ' ' This script demonstrates how to loop through GSM files in a given directory ' and swap the PID and SID for all objects in the base map layers ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub Main 'Initializes everything needed to start MapViewer Dim MapViewer As Object Set mvApp = CreateObject("MapViewer.Application") mvApp.Visible = True 'Open MapViewer's Open dialog box Directory = "C:\Program Files\Golden Software\MapViewer 8\Samples\" 'CHANGE THIS DIRECTORY file$ = Dir$(Directory + "*.gsm") While file$ <> "" 'Open the file in the directory in order Set Plot1 = mvApp.Documents.Open(Directory+file$) 'Loops through all the layers in the file For i = 1 To Plot1.Layers.Count 'Enters the If statement if the layer is a base layer If Plot1.Layers(i).GetMap Is Nothing Then 'Activates the layer, selects everything in the layer, and swaps the PID and SID Plot1.Layers(i).Activate Plot1.Layers(i).Shapes.SelectAll Plot1.Layers(i).Selection.RedefineAttributes(PIDField:=mvAttribTypeSID, SIDField:=mvAttribTypePID, _ Attrib1Field:=mvAttribTypeAttrib1, Attrib2Field:=mvAttribTypeAttrib2, HyperlinkField:=mvAttribTypeHyperlink) Plot1.Layers(i).Selection.DeselectAll End If Next i 'Resave file as MapViewer file with a new name Plot1.SaveAs(Directory + file$ + "_PIDisSID.gsm") 'Close the plot window Plot1.Close() 'Open the next file file$ = Dir$() Wend End Sub
Updated November 2, 2016
Comments
0 comments
Please sign in to leave a comment.