This article contains a sample script for changing the fill of all closed objects and the line properties of all polyline and spline polyline objects.
To run this script:
- Copy the text below, from the Sub Main start line to the End Sub end line, or click here to download the BAS file: ChangeSharedProperties.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.
'============================== ' Change_Shared_Properties.bas ' ' Selects all closed shapes in the open GSM and changes the fill properties, ' then selects all closed shapes and lines and changes the line properties. ' ' ---------TO USE THIS SCRIPT------- ' Have MapViewer running with your GSM file open ' then run this script from within Scripter. '============================== Sub Main Dim mvApp, Plot, CurrentLayer, MapShapes As Object Set mvApp = GetObject(,"MapViewer.Application") mvApp.Visible = True Set Plot = mvApp.ActiveDocument 'Go through all the layers in the map For layerNum=1 To Plot.Layers.Count Set CurrentLayer = Plot.Layers.Item(layerNum) Set MapShapes = CurrentLayer.Shapes 'Selects all closed shapes (polygons, spline polygons, rectangles, squares, rounded rectangles, 'rounded squares, ellipses, circles) and changes the fill properties of all at once MapShapes.SelectByType(Area:=True, Rectangle:=True, RoundedRect:=True, Square:=True, _ Ellipse:=True, Circle:=True) For i=1 To CurrentLayer.Selection.Count 'Loop through the selected items and change their fill properties Set closedshape = CurrentLayer.Selection.Item(i) closedshape.Fill.Pattern = "Diagonal Cross" closedshape.Fill.ForeColor = mvColorBlue Next CurrentLayer.Selection.DeselectAll 'Selects all closed shapes plus all polylines and spline polylines and changes the line properties MapShapes.SelectByType(Area:=True, Curve:=True, Rectangle:=True, RoundedRect:=True, _ Square:=True, Ellipse:=True, Circle:=True) For i=1 To CurrentLayer.Selection.Count 'Loop through the selected items and change their line properties Set shapeswithline = CurrentLayer.Selection.Item(i) shapeswithline.Line.Style = ".1 in. Dash" shapeswithline.Line.color = mvColorRed Next Next End Sub
Updated September 10, 2018