<?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: convert script from arcmap env to arcgis pro env in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099679#M45719</link>
    <description>&lt;P&gt;It looks to me list you need to add another loop - to process the &lt;STRONG&gt;list&lt;/STRONG&gt; of layouts that your get from the call to listLayouts.&amp;nbsp; Like this&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for lyts in aprx.listLayouts("Layout 1"):
    for lyt in lyts:
        for elm in lyt.listElements("TEXT_ELEMENT"):
            if elm.name == "Text":
                elm.text = wl


&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 19 Sep 2021 12:23:16 GMT</pubDate>
    <dc:creator>DonMorrison1</dc:creator>
    <dc:date>2021-09-19T12:23:16Z</dc:date>
    <item>
      <title>convert script from arcmap env to arcgis pro env</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099616#M45707</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os

arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")

df = arcpy.mapping.ListDataFrames(mxd)[0]

layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []

layerFile = arcpy.mapping.Layer(layerName)
layerFile.definitionQuery = ""

print df.name


with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
    for row in cursor:
        for item in row:
            whereList.append(item)

for wl in whereList:

    arcpy.RefreshActiveView()
    mxd.save()   
    layerFile.definitionQuery = fieldName + "= '" + wl + "'"
    new_extent = layerFile.getExtent()
    df.extent = new_extent
    df.scale *= 1.5
    
    for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "title"):      
    
        if elm.name == "title":
           elm.text = wl

    arcpy.RefreshActiveView()
    outFile = os.path.join(imgLocation, wl + ".pdf")
    arcpy.AddMessage(outFile)
    outFile = imgLocation + "\\" + wl + ".pdf"   
    arcpy.mapping.ExportToPDF(mxd, outFile, "PAGE_LAYOUT")
del mxd&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Sep 2021 13:35:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099616#M45707</guid>
      <dc:creator>MahmoudHegazy</dc:creator>
      <dc:date>2021-09-18T13:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: convert script from arcmap env to arcgis pro env</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099633#M45708</link>
      <description>&lt;P&gt;What line was your first error encountered on?&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/main/arcgis-pro-arcpy-reference.htm" target="_blank"&gt;ArcGIS Pro Python reference—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;as a start...&lt;/P&gt;&lt;P&gt;hints&lt;/P&gt;&lt;P&gt;mapping ---&amp;gt;&amp;nbsp; mp&lt;/P&gt;&lt;P&gt;print "blah" ---&amp;gt; print("blah")&lt;/P&gt;&lt;P&gt;work your way through the code so you can learn the translation as you go&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Sep 2021 18:15:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099633#M45708</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-09-18T18:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: convert script from arcmap env to arcgis pro env</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099640#M45712</link>
      <description>&lt;P&gt;&lt;STRONG&gt;i don't know what is the erorr exactly&amp;nbsp;&lt;/STRONG&gt;&amp;nbsp;line 31&lt;BR /&gt;&lt;STRONG&gt;for lyt in aprx.listLayouts("Layout"):&amp;nbsp;SyntaxError: invalid syntax&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os

arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject("CURRENT")
df = aprx.listMaps()[0]

layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []

layerFile = df.listLayers(layerName)[0]
layerFile.definitionQuery = ""

print ((df.name))


with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
    for row in cursor:
        for item in row:
            whereList.append(item)

for wl in whereList:      
    layerFile.definitionQuery = fieldName + "= '" + wl + "'"
    #new_extent = layerFile.getExtent()
    lay = aprx.listLayouts("Layout")
    mf = lay.listElements("Layers Map Frame","New Data Frame Map Frame")
    new_extent = mf.camera.setExtent(mf.getLayerExtent(layerFile, False, True)
    #df.extent = new_extent
    #df.scale *= 1.5
    for lyt in aprx.listLayouts("Layout"):
        for elm in lyt.listElements("TEXT_ELEMENT"):
            if elm.name == "Text":
                elm.text = wl          &lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 18 Sep 2021 23:45:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099640#M45712</guid>
      <dc:creator>MahmoudHegazy</dc:creator>
      <dc:date>2021-09-18T23:45:02Z</dc:date>
    </item>
    <item>
      <title>error in syntax arcpy in arcgis pro enviroment</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099645#M45714</link>
      <description>&lt;P&gt;syntax error in line 31:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os

arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject("CURRENT")
df = aprx.listMaps()[0]

layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []

layerFile = df.listLayers(layerName)[0]
layerFile.definitionQuery = ""

print ((df.name))


with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
    for row in cursor:
        for item in row:
            whereList.append(item)

for wl in whereList:      
    layerFile.definitionQuery = fieldName + "= '" + wl + "'"
    #new_extent = layerFile.getExtent()
    lay = aprx.listLayouts("Layout")
    mf = lay.listElements("Layers Map Frame","New Data Frame Map Frame")
    new_extent = mf.camera.setExtent(mf.getLayerExtent(layerFile, False, True)
    #df.extent = new_extent
    #df.scale *= 1.5
    for lyt in aprx.listLayouts("Layout"):
        for elm in lyt.listElements("TEXT_ELEMENT"):
            if elm.name == "Text":
                elm.text = wl          &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Sep 2021 23:57:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099645#M45714</guid>
      <dc:creator>MahmoudHegazy</dc:creator>
      <dc:date>2021-09-18T23:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: convert script from arcmap env to arcgis pro env</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099648#M45715</link>
      <description>&lt;P&gt;missing a closing bracket in&lt;/P&gt;&lt;P&gt;new_extent = mf.camera.setExtent(mf.getLayerExtent(layerFile, False, True)&lt;/P&gt;&lt;P&gt;should be&lt;/P&gt;&lt;P&gt;new_extent = mf.camera.setExtent(mf.getLayerExtent(layerFile, False, True))&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 01:16:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099648#M45715</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-09-19T01:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: convert script from arcmap env to arcgis pro env</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099664#M45716</link>
      <description>&lt;P&gt;after i put the bracket it showed me this message error&lt;/P&gt;&lt;P&gt;AttributeError: 'list' object has no attribute 'listElements'&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os

arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject("CURRENT")
df = aprx.listMaps()[0]

layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []

layerFile = df.listLayers(layerName)[0]
layerFile.definitionQuery = ""

print ((df.name))


with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
    for row in cursor:
        for item in row:
            whereList.append(item)

for wl in whereList:      
    layerFile.definitionQuery = fieldName + "= '" + wl + "'"
    #new_extent = layerFile.getExtent()
    lay = aprx.listLayouts("Layout 1")
    mf = lay.listElements("Layers Map Frame","New Data Frame Map Frame")
    new_extent = mf.camera.setExtent(mf.getLayerExtent(layerFile, False, True))
    #df.extent = new_extent
    #df.scale *= 1.5
    for lyt in aprx.listLayouts("Layout 1"):
        for elm in lyt.listElements("TEXT_ELEMENT"):
            if elm.name == "Text":
                elm.text = wl          
     
    name = ''
    for char in wl:
        if char.isalpha():
            name+=char

    outFile = imgLocation + "\\" + name  + ".pdf"   
    arcpy.mp.ExportToPDF(aprx, outFile, "PAGE_LAYOUT")
del aprx&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the two data frame called as you see in the screen shot blow :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 07:56:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099664#M45716</guid>
      <dc:creator>MahmoudHegazy</dc:creator>
      <dc:date>2021-09-19T07:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: convert script from arcmap env to arcgis pro env</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099673#M45717</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/textelement-class.htm" target="_blank"&gt;TextElement—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp; has some code examples, you may need to examine the required workflow&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 09:19:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099673#M45717</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-09-19T09:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: convert script from arcmap env to arcgis pro env</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099679#M45719</link>
      <description>&lt;P&gt;It looks to me list you need to add another loop - to process the &lt;STRONG&gt;list&lt;/STRONG&gt; of layouts that your get from the call to listLayouts.&amp;nbsp; Like this&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for lyts in aprx.listLayouts("Layout 1"):
    for lyt in lyts:
        for elm in lyt.listElements("TEXT_ELEMENT"):
            if elm.name == "Text":
                elm.text = wl


&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 12:23:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-script-from-arcmap-env-to-arcgis-pro-env/m-p/1099679#M45719</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2021-09-19T12:23:16Z</dc:date>
    </item>
  </channel>
</rss>

