VECGetSelection, VECRemoveSelection, and VECSetSelection

Demonstrate how to set and get selection of shapes in a layer.

Remarks

This example illustrates how to select five shapes, get the selected shapes and print them. It then removes the selection and tries to do another selection of the shapes.

Code

 local int layer
 local int tfid, int i
 local int ShapeArray[5], int ptr ShapesOut
 local string temp_file

 try

    temp_file = "./my.pix"
    delete temp_file noerror
    call CopyFile( GetPCIHOME() + "/demo/irvine.pix", \
                 temp_file)

    tfid = DBOpen(temp_file, "r+")

    layer = 31

    ShapeArray[1] = 4
    ShapeArray[2] = 6
    ShapeArray[3] = 8
    ShapeArray[4] = 9
    ShapeArray[5] = 12

    call VECSetSelection(tfid, layer, ShapeArray)

    ShapesOut = VECGetSelection(tfid, layer)
    for i = 1 To 5
        print "Shape ", i, ": ", ShapesOut(i)
    endfor

    call VECRemoveSelection(tfid, layer, ShapeArray)
    print "Remove selection now"

    ShapesOut = VECGetSelection(tfid, layer)
    print "Shapes left:", F$Len( ShapesOut )

    call EFree( ShapesOut )
    call DBClose(tfid)

 onerror
   print "Error: "+ GetLastErrorMessage()
 endonerror

Output

Shape 1: 4
Shape 2: 6
Shape 3: 8
Shape 4: 9
Shape 5: 12
Remove selection now
Shapes left:0

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.