Sub Multiple_Polls() Dim pDoc As IMxDocument Set pDoc = ThisDocument Dim pMap As IMap Set pMap = pDoc.FocusMap Dim pLayer As IFeatureLayer Dim pFSel As IFeatureSelection Set pLayer = pMap.Layer(3) Set pFSel = pLayer 'Get the selected features Dim pSelSet As ISelectionSet Set pSelSet = pFSel.SelectionSet Dim pEnumGeom As IEnumGeometry Dim pEnumGeomBind As IEnumGeometryBind Set pEnumGeom = New EnumFeatureGeometry Set pEnumGeomBind = pEnumGeom pEnumGeomBind.BindGeometrySource Nothing, pSelSet Dim pGeomFactory As IGeometryFactory Set pGeomFactory = New GeometryEnvironment Dim pGeom As IGeometry Set pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom) pDoc.ActiveView.Extent = pGeom.Envelope pDoc.ActiveView.Refresh End Sub
Set pLayer = pMap.Layer(3)
Have you considered using arcpy.mapping? It is a great substitute for many common tasks and can accomplish what you are trying to do.
You can change query definitions on a layer using the layer object:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/
For good resources on how to get started, check out:
http://blogs.esri.com/esri/arcgis/2011/09/30/new-resources-available-for-getting-started-with-python...
Jeff
I work for the gov't and because of that it's virtually impossible to convince IT that I need additional components installed and if I do it'll take months of hassle. Does arcpy.mapping require installation of something python related or is it defaulted in the ARCMap install?
Python and the arcpy module are installed by default with ArcGIS Desktop.
mxd = arcpy.mapping.MapDocument("current") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] lyr = arcpy.mapping.ListLayers(mxd, "myLayer")[0] #Zoom to all selected features in data frame df.zoomToSelectedFeatures() #Zoom to selected features for a specific layer. df.extent = lyr.getSelectedExtent() arcpy.RefreshActiveView()