I'm developing an ArcMap add-in that will run a trace against a water main that the user has selected using the selection tool. The geometric network is already defined and I can run the trace by manually placing the edge barriers at each end of the main, putting an edge flag somewhere on the water main between the edge barriers and then tracing downstream (using indeterminate flow). This returns all the curbstop valves that are connected to the water main.
I'd like to automate this so that the user doesn't need to place barriers or flag(s) but just needs to select the water main and hit a button to preform the trace. I guess my pseudocode would be something like:
- User selects a water main
- User clicks my Add-In button
- Programmatically place Edge Barrier at both ends of selected water main segment
- Programmatically place Flag somewhere between barriers to indicate where to start trace from
- Run the trace
Is what I want to do even possible? How can I add flags and barriers to a selected segment of a geometric network using ArcObjects?