I'm trying to find an add-in that allows me to enter a parcel#, select, then zoom to that parcel. I have seen "zoom to attribute" examples but nothing that allows me to enter parcel numbers. The add-in would be used by me to zoom to the parcel without having to open attribute table find the parcel number (out of thousands) then zoom to.This is the code I have used, which selects all the parcels and then zooms to extent the layer name is "Parcel_Link" and the Field that holds the parcel number is PIN mxd = arcpy.mapping.MapDocument('CURRENT')... df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]... Parcel_Link = arcpy.mapping.ListLayers('CURRENT', Parcel_Link, df)[0]... whereClause = "PIN ='%s'" % Parcel_Link... arcpy.SelectLayerByAttribute_management("Parcel_Link", "NEW_SELECTION", whereClause)... df.extent = Parcel_Link.getSelectedExtent(True)... df.scale *= 1.5... arcpy.RefreshActiveView()Any input would be niceThanksJoby
import arcpy arcpy.AddMessage("Starting") pu = arcpy.GetParameterAsText(0) arcpy.AddMessage(pu) mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0] lyr = arcpy.mapping.ListLayers(mxd, "PLANNING UNIT", df)[0] arcpy.AddMessage(lyr.name) expression = "PLANNINGUNIT = '"+pu+"'" arcpy.AddMessage(expression) arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",expression) df.extent = lyr.getSelectedExtent() df.scale = df.scale*1.1 for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "PU"): if elm.name == "PU": elm.text = (pu) arcpy.SelectLayerByAttribute_management(lyr,"CLEAR_SELECTION") arcpy.RefreshActiveView() arcpy.AddMessage("Completed")
I hear your frustration, i don't understand why ESRI is not going to be using VBA anymore.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.