Interactively select shapefile?

904
1
08-27-2012 09:59 AM
StephenFricke
New Contributor III
I was curious if anyone knew how I would go about creating a tool which allowed the user to select a shapefile from an interactive map, for example select a particular state from a shapefile of all the states in the U.S. and then the tool will use that particular state shapefile as the clipping extent for the tool.  I have a climate dataset for the entire United States and I would like the user to be able to select a particular state on a map so the climate dataset is clipped to just that state.  I know how to add the shapefile as a parameter on the tool's gooey, but instead of the user navigating to a shapefile saved somewhere on their computer, I would like them to be able to interactively select that state's shapefile on a map and then that shapefile will be used as the clip extent.  If anyone has an idea about how I would go about this please share, thanks!!
Tags (2)
0 Kudos
1 Reply
RichardFairhurst
MVP Honored Contributor
I was curious if anyone knew how I would go about creating a tool which allowed the user to select a shapefile from an interactive map, for example select a particular state from a shapefile of all the states in the U.S. and then the tool will use that particular state shapefile as the clipping extent for the tool.  I have a climate dataset for the entire United States and I would like the user to be able to select a particular state on a map so the climate dataset is clipped to just that state.  I know how to add the shapefile as a parameter on the tool's gooey, but instead of the user navigating to a shapefile saved somewhere on their computer, I would like them to be able to interactively select that state's shapefile on a map and then that shapefile will be used as the clip extent.  If anyone has an idea about how I would go about this please share, thanks!!


Python is incapable of setting a data frame's clip geometry.  It has no arcpy.mapping method to do that.  So if that is what you mean by setting a clip extent then you must use the IMap.ClipGeometry ArcObjects interface.  I am programming an Add-In extension that will listen to AfterDraw events and watch a hidden text object in my map to get messages from Python to set a data frame clip after a long Python script.  If want your routine to use the shapefile in connection with the Clip geoprocessing tool that is a different matter (straight Python can do that), but I would normally assume that an interactive map involves dealing with data frame clipping.
0 Kudos