Below is the example code listing and saved to a script file test.py.
#import gvSIG library from gvsiglib import * #get the map view mapview = gvSIG.getActiveDocument() #get the map control mapctrl = mapview.getMapControl() #get the map context mapctx = mapctrl.getMapContext() #print the list of layers in the map view and the record count for each layer for i in range(mapctx.getLayers().getLayersCount()): layer = mapctx.getLayers().getLayer(i) rs = layer.getRecordset() print "%s,%d records" % (layer.getName(), rs.getRowCount())
- Start up gvSIG OADE 2010. Open a Map View. Load in a couple of layers e.g. BLDG.shp and layer1.shp.
- Select File | Scripting | Jython Console.
The Jython window appears.
- At the Jython prompt, type in: execfile ("c:/temp/test.py").
The script is loaded and executed listing out the layers and the number of records.
Instead of loading from a script file, the Jython Console can accept typing in the code line by line in the Console prompt. However, I find using a script file is more convenient.