Working in Edit session, trying to go from Edit Sketch to Feature...

533
3
01-24-2012 08:00 AM
KevinOrcutt
New Contributor
Howdy All,
This one should be easy, but for the life of me I can't make heads or tails /sense out of it... I am trying to write the code for a button/command that the user will click after they've finshed a "Edit Sketch"... I want to take the sketch (which is a polygon in this case) and get to the feature that it created... I need to modify a couple of attributes, then run a "select by location" on it to get the underlining lines (from a different layer) that intersect it. then clear the selection on the "Polygon" layer and run a topology operation of "Split polygons" with the lines selected... Seems pretty simple when i go through the motions manually... but I can't seem to get ther from here with the code version... 🙂 I've been through the numerous webpages on the resource page under "Developing with ArcGIS - Learning ArcObjects - Editing Data" and under "Developing with ArcGIS - Learning ArcObjects - Extending ArcObjects - Editor Framework Customizations"... But It's not clear to me what I need to next... Basically there's a new feature in the polygon layer, that is also the current edit sketch, that I would like to manipulate as a feature via code... Can I get to the feature from the edit sketch, or do I have to do something else to get to the newly created feature??? then how difficult is it to do the "Select By Location" operation???
Any ideas will be greatly appreciated!!!

Thanks in advance,
Kevin Orcutt
GIS Developer/Consultant
City of Cincinnati - Cincinnati Area GIS (CAGIS)
(513) 850-1335 (cell)
Kevin.Orcutt@cincinnati-oh.gov
www.cagis.org
0 Kudos
3 Replies
AlexanderGray
Occasional Contributor III
The sketch is a transitory object.  It only exists as a precursor to the edit operation.  An edit sketch is a means for an user to manipulate a geometry (shape.)  A geometry is a property of the feature (row in a featureclass.)  So basically to create a new feature, you start with an empty sketch, you add vertices to the sketch to create the sketch geometry.  When finish sketch is invoked, an edit operation is started, a feature is created and it's shape property is set to the sketch's geometry and the edit operation is completed.  The sketch is then discarded. 

So if you want to click a button after a feature has been created, you need to run it off the selection (what if the user clicks on the button when no sketch has been done, what if the sketch was used to modify a feature, etc.)  You could also listen to edit events after a feature was created or added.  Regardless you need to get the geometry from the feature (selection or edit event) and use that to do your select by location.  You can get the lines that intersect the polygon by doing a query with a Spatial Filter (do a search cursor on the line featureclass with a spatialfilter as a query filter argument.)  The get all the geometries of the line features, merge them together (union) and split the polygon feature (Ifeatureedit)
0 Kudos
KevinOrcutt
New Contributor
OK Alexander,
   I've followed most of what you've said.  And I have progressed to the point where I need to "Split" the polygon with the selected lines... per your quote:
The get all the geometries of the line features, merge them together (union) and split the polygon feature (Ifeatureedit)


How does one go about "Splitting" the polygon with this collection of line geometeries...  I have'nt gotten the collection of geometeries yet, but i have a selectionset of the lines, so getting the geometries isn't too hard from what I got so far...  Just NOT sure on the "Splitting" part..

Thanks again in advance,
Kevin
0 Kudos
AlexanderGray
Occasional Contributor III
Depends what you have to split, a geometry or a feature.  If your polygon is already stored in a feature in the featureclass and you want as many features as there will be polygons split by the lines, then cast the Ifeature to an IFeatureEdit and split.  That will create new features in the database according to the split rules you have set up in your featureclass.  If you have a polygon geometry (shape not attached to a feature yet) or you don't want to store the result in the featureclass, then you would cast your polygon to an ITopologicalOperator4 and call cut2.  Cut2 returns a collection of the polygons which will be created by splitting the polygon with the line (just one line so union the lines into one shape first)  Then you have the polygons to do what ever you want with (create new features, draw on map, do other topological operations)
If you get a polygon shape from a feature and you don't want to change the original, I suggest you user IFeature.ShapeCopy before doing any thing.
0 Kudos