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 creating shapes.
To run this script:
- Copy the script below, or click here to download the BAS file: Shape.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.
*********
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Shape.BAS ' Copyright (C) Golden Software Inc. 1992-2015 ' ' This sample demonstrates how to create shapes. ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub Main Dim MapViewerApp As Object 'Creates an instance of the MapViewer Application object ' and assigns it to the variable named "MapViewerApp" Set MapViewerApp = CreateObject("MapViewer.Application") 'Makes the application main window visible MapViewerApp.Visible = True 'Creates a map document object, and assigns it to the variable named "doc" Set doc = MapViewerApp.Documents.Add(DocType:=mvDocPlot) 'Assigns the layers list object to the variable named "Layers" Set Layers = doc.Layers 'Assigns the layer object to the variable named "Layer" Set Layer = Layers.ActiveLayer 'Assigns the shapes list object to the variable named "Shapes" Set Shapes = Layer.Shapes 'Adds an area object NumPoints = 4 ReDim PolyPoints (1 To NumPoints * 2) As Double PolyPoints(1) = 6.0 PolyPoints(2) = 4.5 PolyPoints(3) = 7.0 PolyPoints(4) = 4.5 PolyPoints(5) = 6.5 PolyPoints(6) = 5.5 PolyPoints(7) = 6.0 PolyPoints(8) = 4.5 Set Area = Shapes.AddPolygon(False,PolyPoints) 'Checks Vertices Dim v() As Double v = Area.Vertices 'UBound is 0 based. If UBound(v) <> 7 Then Stop 'Allocates space 5 more vertices i = UBound(v) 'Current last element of v ReDim Preserve v(i + 2 * 5) 'Assigns values for the new polygon v(i + 1) = 4: v(i + 2) = 3 v(i + 3) = 9: v(i + 4) = 3 v(i + 5) = 9: v(i + 6) = 6.5 v(i + 7) = 4: v(i + 8) = 6.5 v(i + 9) = 4: v(i + 10) = 3 'Sets space for 2 poly counts Dim c(1 To 2) As Long c(1) = 4 'The first polygon has 4 vertices c(2) = 5 'The second polygon has 5 vertices 'Updates the area object Area.SetVertices v, c 'Changes the Fill patter and foreground color for the area Area.Fill.Pattern = "Solid" Area.Fill.ForeColor = mvColorRed 'Changes the line color of the area Area.Line.Color = mvColorGreen 'Creates PID for the area Area.PIDName = "Polygon #1 PID" 'Creates SID for the area Area.SIDName = "Polygon #1 SID" 'Creates attrib1 for the area Area.Attrib1 = "Polygon #1 Attrib1" 'Creates attrib2 for the area Area.Attrib2 = "Polygon #1 Attrib2" 'The total number of objects in the shape list should be 3 (area, PID and SID) If Shapes.Count <> 3 Then Stop 'Docs.CloseAll 'MapViewerApp.Quit End Sub
Updated November 2, 2016
Comments
0 comments
Please sign in to leave a comment.