English

How To: View the spatial index grids associated with a DBTheme

Summary

The following script will display the spatial index grids of a DBTheme. Spatial indexes increase the selection speed of graphical queries on spatial features. It is much faster to first look up the index and then go to the appropriate record than to start at the first record and search through the entire table.

Warning:
Building a new spatial index for an ArcSDE feature class is a very server-intensive operation. It should not be done on very large feature classes when a large number of users are logged in to the server.

Procedure

The following script is an example. A DBTheme must be active in a view.

  1. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Copy and paste the code into the new script window.

    Code:
    '-------------------
    theview = av.getactivedoc
    thetheme = theview.getactivethemes.get(0)
    theqd = thetheme.getquerydef
    thescol = thetheme.getscolumn
    theglist = theview.getgraphics
    theext = thetheme.returnextent
    theo = theext.returnorigin
    thes = theext.returnsize
    thegrids = thescol.getgridsizes
    thegridsize = msgbox.listasstring(thegrids,"Select Grid Size:","Grid Sizes")
    x = theo.asstring.aslist.get(1).asnumber
    y = theo.asstring.aslist.get(2).asnumber
    maxx = x + thes.asstring.aslist.get(1).asnumber
    maxy = y + thes.asstring.aslist.get(2).asnumber
    xc = x.clone
    xy = y.clone

    while (x <= maxx)
    thexline = polyline.make({{x@y, x@maxy}})
    thegshapex = graphicshape.make(thexline)
    thegshapex.getsymbol.setcolor(color.getblue)
    theglist.add(thegshapex)
    x = x + thegridsize
    end

    while (y <= maxy)
    theyline = polyline.make({{xc@y, maxx@y}})
    thegshapey = graphicshape.make(theyline)
    thegshapey.getsymbol.setcolor(color.getblue)
    theglist.add(thegshapey)
    y = y + thegridsize
    end

    av.purgeobjects
    '-------------


    Note:
    For more information on spatial index grid sizes, see the SDE Administrators Guide

  3. Click the compile button.
    [O-Image] Script compile button
  4. Click the run button.
    [O-Image] Run compiled script button