Loop through attributes in a layer and zoom to selected feature

2704
5
Jump to solution
10-20-2014 03:08 AM
JohannesBierer
Occasional Contributor III

Is there a working solution `somewhere in python?

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

Not that would be really useful...I just normally select what I need via a query for instance, get into edit mode, use the show selected records only option within the table, edit a cell, click on the next one, edit it etc etd.  I don't have much use for auto-auto-automation.  For example your workflows suggests you query for records then want to click a button, to go to the next selected record, then click in that cell, edit it click on the button again etc etc.  that you would be adding a step to my suggested one.

Better if you have a query that you can use to do the selection for the "bad" ones (or "good") or via manual selection... why not do it...launch the field calculator and type in the 1 or zero..then switch the selection and use the field calculator to do the opposite case.

Ignore this totally if you needs are significantly different

View solution in original post

0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus

yes the arcpy.mapping module, specifically in the dataframe section.  Have a good read through that whole helpfile section, it is quite good

JohannesBierer
Occasional Contributor III

Thanks Dan,

it's really good, but what i need is a button to loop through attributes, manually edit something (like insert in attribute table a 1 for error and 0 for no error) and loop to the next?

Is this possible?

This is what I have so far, but how to stop the loop after each for statement and restart in python the place I left the loop?

import arcpy

import os

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")

df = arcpy.mapping.ListDataFrames(mxd, "")[0]

SelLayer = arcpy.mapping.ListLayers(mxd, "Aenderung_MToS_6417341", df)[0]

for row in arcpy.SearchCursor(SelLayer):

    df.extent = row.SHAPE.extent #Set the dataframe extent to the extent of the feature

    df.scale = df.scale * 1.07 #Optionally give the shape a bit of padding around the edges

    arcpy.RefreshActiveView()

    #Put in your export here

0 Kudos
JohannesBierer
Occasional Contributor III

Or is it possible to connect the restart of the loop to the save edits button in the editor menu?

0 Kudos
DanPatterson_Retired
MVP Emeritus

Not that would be really useful...I just normally select what I need via a query for instance, get into edit mode, use the show selected records only option within the table, edit a cell, click on the next one, edit it etc etd.  I don't have much use for auto-auto-automation.  For example your workflows suggests you query for records then want to click a button, to go to the next selected record, then click in that cell, edit it click on the button again etc etc.  that you would be adding a step to my suggested one.

Better if you have a query that you can use to do the selection for the "bad" ones (or "good") or via manual selection... why not do it...launch the field calculator and type in the 1 or zero..then switch the selection and use the field calculator to do the opposite case.

Ignore this totally if you needs are significantly different

0 Kudos
JohannesBierer
Occasional Contributor III

Your right, get a bit lost in "auto-auto-automotation". I like this word

0 Kudos