Even as Johns script is fab, it walks the whole db, and I need it to only walk a list of selected polygons. I hate asking and asking.
You can certainly reuse bits of John’s script to apply to individual selected polygons. Try the Edit>Code Snippet tool in the Script Editor and choose Select List Iterator. This will insert skeleton code you can fill in with your custom code. With the code it produces, use the “rec” and apply John’s functions to “clear” the items you want on the polygons.
The following is an example of how you could adapt John’s code easily (using the Code Snippet spit out) to process the select list instead of the whole database. Programmer’s will cringe when they see how I’ve misused John’s original “Clear” function but this will work (but admittedly not very elegantly).
def ClearSMCIndex (db, parent, rec, i):
if (mgGetCode(rec) == fltPolygon):
mgSetAttList (rec, fltPolySmc, 1)
return MG_TRUE
db = mgGetCurrentDb()
selectList = mgGetSelectList (db)
num = mgGetRecListCount (selectList)
if (num == 0):
mgSendMessage (MMSG_ERROR, "Nothing selected")
else:
print "Selected Nodes:"
for i in range (0, num):
rec,m = mgGetNextRecInList (selectList)
ClearSMCIndex (None, None, rec, None)
If you wanted to be more elegant, you could refactor the Clear functions a bit as suggested here:
def ClearPolySMCIndex (rec):
mgSetAttList (rec, fltPolySmc, 1)
def ClearSMCIndex (db, parent, rec, i):
if (mgGetCode(rec) == fltPolygon):
ClearPolySMCIndex
return MG_TRUE
db = mgGetCurrentDb()
selectList = mgGetSelectList (db)
num = mgGetRecListCount (selectList)
if (num == 0):
mgSendMessage (MMSG_ERROR, "Nothing selected")
else:
print "Selected Nodes:"
for i in range (0, num):
rec,m = mgGetNextRecInList (selectList)
if (mgGetCode(rec) == fltPolygon):
ClearPolySMCIndex (rec)