Working on C# code that will allow user to create "Barriers" on a map

11-17-2011 03:45 AM
Occasional Contributor
Right now, I have code that allows the user to indicate on a map (that contains a Network Dataset layer) "Stops" that are needed to create a "Route". I need to add the functionality to the interface that allows the user to also create "Barriers" as well as "Stops".

If I do this in ArcMap, after the "Route" layer is created by clicking on "Network Analyst" and "New Route", I would just make the Network Analyst window visible, and then highlight the "Restriction" layer inside the "Line Barriers" layer, and then click on the button for "Create Network Location Tool" which allows me to draw the barrier on the map. I already have implemented the ability to create Stops by using ControlsNetworkAnalystCreateLocationToolClass().

My question is, how can I also implement the capability of creating "Barriers" as well as "Stops" into my code? Thanks, Renee
Tags (2)
0 Kudos
20 Replies
New Contributor
Do you have access to the ArcObject .NET SDK?  If so install it and get one of the installed samples called NAEngine, also found here:

This app shows how to use the ToolbarControl, TOCControl, and MapControl to do network analysis work.  The Create Locations tool is already added to the toolbar, as is the button that opens the NAWindow.

Once there is an active analysis layer in the NAWindow and one of the barriers classes selected in the NAWindow, you can make sure the Create Location tool is selected on the toolbar.  At that point, you will be able to draw barriers appropriately.

Hopefully, this gives you everything you need.  At least, it is a great place to get reference code on how to program network analysis using the engine tools.

Thank you. This helped me.
0 Kudos