I'm trying to create a map that allows a user to input information about a location including lat and long through a geoprocessing tool along with a unique tasking number. I want to then select that point and zoom to it. I'm having 2 problems. The first is when I run my code through the geotool my make feature layer does not appear in the TOC however if I run it in the python window that layer does show up. My second problem is that the Zoom To Selected Feature is not working. It seems to be selecting (if I open the table the correct row is highlighted and the point is symbolized as having been selected) but the active view is not shifting to the point the same way it would if I used the menus in ArcMap. My initial research said that the Select Layer By Attribute only worked on a feature layer so I know why that might be an issue when running through the geoprocessingtool but not sure why it wouldn't work when I run it in the python window which shows the creation of the feature layer. So to clarify my questions: is there a reason that I can???t see the Feature Layer I create (even when I refresh the TOC) when I run my script through the geoprocessing tool? Also, why isn???t the Zoom to Selected Feature not working when my Feature Layer is created and showing in the TOC? Thanks in advance.
#Make Feature Layer from Feature Class arcpy.MakeFeatureLayer_management("Facility_Location","Facility_Lyr") arcpy.RefreshTOC #Select the inputed MAS Number Expression = "MASNumber = "+"'"+ MASNum +"'" arcpy.SelectLayerByAttribute_management("Facility_Lyr", "NEW_SELECTION", Expression) #Zoom to selected attribute (MAS Number) df=arcpy.mapping.ListDataFrames(mxd) df.zoomToSelectedFeatures() arcpy.RefreshActiveView ()