The VLShape class provides a convenient and concise way to access data within a vector layer. For example, the following script checks the vertex lists of all the shapes, and if the first and last vertex do not match, it adds an extra vertex to the end of the list matching the first vertex, thus ensuring each shape represents a closed area. The height or z value of the vertices is ignored. Note also that errors are trapped, and the script ensures the file is correctly closed if an error does occur.
try
local VLShape shape
local Vertex v
local integer n
call shape.Open( "irvine.pix", 25,"w" )
call shape.First()
while ( shape.AtEnd != "TRUE" )
n = shape.numvertices
if ( n > 0 AND \
( shape.vertices[1].x != shape.vertices[n].x OR \
shape.vertices[1].y != shape.vertices[n].y ) ) then
v.x = shape.vertices[1].x
v.y = shape.vertices[1].y
call shape.AddVertex( v )
endif
call shape.Next()
endwhile
call shape.Close()
onerror
call shape.Close()
print getlasterrormessage()
call EASIError( 800, "Failed to close shapes!" )
endonerror
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.