<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Trouble adding Network Analyst Layer to MXD with ArcPy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539466#M42168</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also, Im on arc  10.5. I guess I could install pro on my computer. I did see that the process is easier. If you have any thoughts on the solution without pro, that would be great. Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arjun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Dec 2017 13:51:18 GMT</pubDate>
    <dc:creator>ArjunDongre</dc:creator>
    <dc:date>2017-12-14T13:51:18Z</dc:date>
    <item>
      <title>Trouble adding Network Analyst Layer to MXD with ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539463#M42165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having trouble adding a network analyst layer to an mxd using arcpy. I am not getting any errors, yet the layers don't show up after the script completes. I have tried several ways. The first is doing it all in memory.&amp;nbsp; I am creating a layer, say using MakeClosestFacilityLayer, getting the layer from the created object, then adding it via arcpy.mapping.addLayer. I have also exported the Layer to disk and then created a Layer using arcpy.mapping.Layer and then adding that to the mxd. No luck. Help would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Dec 2017 19:56:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539463#M42165</guid>
      <dc:creator>ArjunDongre</dc:creator>
      <dc:date>2017-12-11T19:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble adding Network Analyst Layer to MXD with ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539464#M42166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;not sure where you are doing this or what you are using, but in arcmap and ArcGIS pro, you make your layers by accessing tools within arctoolbox within your scripts.&amp;nbsp; maybe you could elaborate&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Dec 2017 22:58:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539464#M42166</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-12-11T22:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble adding Network Analyst Layer to MXD with ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539465#M42167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found that when a network dataset it updated, the NA layer in the mxd doesn’t automatically incorporate those changes. The layer must be removed and re-added to the mxd. I host an endpoint on arcserver that has some NA layers. I am automating the republishing of this service. To do this successfully though, I need to remove the layers and add them again. I can remove the layers without a problem. But having difficulty adding them back in. I have also tried exporting the layer to disc and then using the arcpy.mapping.Layer to import it and add to the mxd, but no luck. Here is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   mxd = arcpy.mapping.MapDocument(pathtoMXD)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]&lt;/P&gt;&lt;P&gt;    ndLayer = '';&lt;/P&gt;&lt;P&gt;    layers =  arcpy.mapping.ListLayers(mxd, "", df)&lt;/P&gt;&lt;P&gt;    for lyr in layers:&lt;/P&gt;&lt;P&gt;        if lyr.name == "Closest Facility" or lyr.name == "Route":&lt;/P&gt;&lt;P&gt;            arcpy.mapping.RemoveLayer(df, lyr)&lt;/P&gt;&lt;P&gt;            print "layer removed"&lt;/P&gt;&lt;P&gt;        elif lyr.name =="Standard_CL_ND":&lt;/P&gt;&lt;P&gt;            ndLayer = lyr&lt;/P&gt;&lt;P&gt;            print "found nd layer"&lt;/P&gt;&lt;P&gt;        else:&lt;/P&gt;&lt;P&gt;            pass&lt;/P&gt;&lt;P&gt;    mxd.save()&lt;/P&gt;&lt;P&gt;    cfObject=arcpy.MakeClosestFacilityLayer_na(in_network_dataset=ndLayer, out_network_analysis_layer="Closest Facility",&lt;/P&gt;&lt;P&gt;                                  impedance_attribute="DriveTime", travel_from_to="TRAVEL_TO", default_cutoff="", default_number_facilities_to_find="1",&lt;/P&gt;&lt;P&gt;                                  accumulate_attribute_name="",UTurn_policy="ALLOW_UTURNS", restriction_attribute_name="Oneway", hierarchy="NO_HIERARCHY",&lt;/P&gt;&lt;P&gt;                                  hierarchy_settings="", output_path_shape="TRUE_LINES_WITH_MEASURES", time_of_day="", time_of_day_usage="NOT_USED")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    cfLayer = cfObject.getOutput(0)&lt;/P&gt;&lt;P&gt;    #arcpy.SaveToLayerFile_management (cfLayer,"c:&lt;BR /&gt;publish&lt;BR /&gt;catawba&lt;BR /&gt;CFLayer")&lt;/P&gt;&lt;P&gt;    #addLayer = arcpy.mapping.Layer("c:&lt;BR /&gt;publish&lt;BR /&gt;catawba&lt;BR /&gt;CFLayer.lyr")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    arcpy.mapping.AddLayer(df, cfLayer, "TOP")&lt;/P&gt;&lt;P&gt;    mxd.save()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Dec 2017 13:46:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539465#M42167</guid>
      <dc:creator>ArjunDongre</dc:creator>
      <dc:date>2017-12-14T13:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble adding Network Analyst Layer to MXD with ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539466#M42168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also, Im on arc  10.5. I guess I could install pro on my computer. I did see that the process is easier. If you have any thoughts on the solution without pro, that would be great. Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arjun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Dec 2017 13:51:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539466#M42168</guid>
      <dc:creator>ArjunDongre</dc:creator>
      <dc:date>2017-12-14T13:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble adding Network Analyst Layer to MXD with ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539467#M42169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And I'm actually having trouble adding ANY layers. I've seen other threads about this issue, but it seems that everyone else is running their code within arcmap, not stand-alone, so my case may be different.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Dec 2017 14:36:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539467#M42169</guid>
      <dc:creator>ArjunDongre</dc:creator>
      <dc:date>2017-12-14T14:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble adding Network Analyst Layer to MXD with ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539468#M42170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Before saving the mxd, arcpy.RefreshTOC() and arcpy.RefreshActiveView() must be called. The documentation samples do not show this. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Dec 2017 19:22:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-adding-network-analyst-layer-to-mxd-with/m-p/539468#M42170</guid>
      <dc:creator>ArjunDongre</dc:creator>
      <dc:date>2017-12-14T19:22:25Z</dc:date>
    </item>
  </channel>
</rss>

