<?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: Migrate script tool with parameters to ArcGIS Pro in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/migrate-script-tool-with-parameters-to-arcgis-pro/m-p/1014162#M25006</link>
    <description>&lt;P&gt;Because Pro has multiple layouts, you need to get the layout as well.&lt;/P&gt;&lt;P&gt;Try something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
lyt = aprx.listLayouts("your_layout_name")[0]
for elm in lyt.listElements("TEXT_ELEMENT"):
  if elm.name == 'SiteName':
    elm.text = SiteName 
  elif elm.name == 'Address':
     elm.text = Address&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jan 2021 00:26:41 GMT</pubDate>
    <dc:creator>MarkBryant</dc:creator>
    <dc:date>2021-01-06T00:26:41Z</dc:date>
    <item>
      <title>Migrate script tool with parameters to ArcGIS Pro</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrate-script-tool-with-parameters-to-arcgis-pro/m-p/1014160#M25005</link>
      <description>&lt;P&gt;I have a script from an ArcMap toolbox that updates text elements in the MXD as user input parameters below. I am trying to update this to work in Pro, but I am having trouble finding resources. I have tried updating certain codes in the second snippet below with text in bold.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Original:&lt;/P&gt;&lt;PRE&gt;import arcpy &lt;BR /&gt;mxd = arcpy.mapping.MapDocument("CURRENT") &lt;BR /&gt;&lt;BR /&gt;# Defines Address Element Name&lt;BR /&gt;SiteName = arcpy.GetParameterAsText(0).upper()&lt;BR /&gt;Address = arcpy.GetParameterAsText(1).upper()&lt;BR /&gt;PreplanID = arcpy.GetParameterAsText(2).upper()&lt;BR /&gt;CrossStreet = arcpy.GetParameterAsText(3).upper()&lt;BR /&gt;Floor = arcpy.GetParameterAsText(4).lower()&lt;BR /&gt;&lt;BR /&gt;# Autopopulate Remaining Text Elements from User Inputs and Cursor search&lt;BR /&gt;for elm in arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT"):&lt;BR /&gt;if elm.name == 'SiteName':&lt;BR /&gt;elm.text = SiteName &lt;BR /&gt;elif elm.name == 'Address':&lt;BR /&gt;elm.text = Address&lt;BR /&gt;elif elm.name == 'PreplanID':&lt;BR /&gt;elm.text = PreplanID &lt;BR /&gt;elif elm.name == 'CrossStreet':&lt;BR /&gt;elm.text = CrossStreet&lt;BR /&gt;elif elm.name == 'Floor':&lt;BR /&gt;elm.text = Floor&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Failing update:&lt;/P&gt;&lt;PRE&gt;import arcpy &lt;BR /&gt;&lt;STRONG&gt;aprx&lt;/STRONG&gt; = arcpy.&lt;STRONG&gt;mp.ArcGISProject&lt;/STRONG&gt;("CURRENT") &lt;BR /&gt;&lt;BR /&gt;# Defines Address Element Name&lt;BR /&gt;SiteName = arcpy.GetParameterAsText(0).upper()&lt;BR /&gt;Address = arcpy.GetParameterAsText(1).upper()&lt;BR /&gt;PreplanID = arcpy.GetParameterAsText(2).upper()&lt;BR /&gt;CrossStreet = arcpy.GetParameterAsText(3).upper()&lt;BR /&gt;Floor = arcpy.GetParameterAsText(4).lower()&lt;BR /&gt;&lt;BR /&gt;# Autopopulate Remaining Text Elements from User Inputs and Cursor search&lt;BR /&gt;for elm in arcpy.&lt;STRONG&gt;mp&lt;/STRONG&gt;.ListLayoutElements(&lt;STRONG&gt;aprx&lt;/STRONG&gt;,"TEXT_ELEMENT"):&lt;BR /&gt;if elm.name == 'SiteName':&lt;BR /&gt;elm.text = SiteName &lt;BR /&gt;elif elm.name == 'Address':&lt;BR /&gt;elm.text = Address&lt;BR /&gt;elif elm.name == 'PreplanID':&lt;BR /&gt;elm.text = PreplanID &lt;BR /&gt;elif elm.name == 'CrossStreet':&lt;BR /&gt;elm.text = CrossStreet&lt;BR /&gt;elif elm.name == 'Floor':&lt;BR /&gt;elm.text = Floor&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 00:18:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrate-script-tool-with-parameters-to-arcgis-pro/m-p/1014160#M25005</guid>
      <dc:creator>Brian_McLeer</dc:creator>
      <dc:date>2021-01-06T00:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Migrate script tool with parameters to ArcGIS Pro</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrate-script-tool-with-parameters-to-arcgis-pro/m-p/1014162#M25006</link>
      <description>&lt;P&gt;Because Pro has multiple layouts, you need to get the layout as well.&lt;/P&gt;&lt;P&gt;Try something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
lyt = aprx.listLayouts("your_layout_name")[0]
for elm in lyt.listElements("TEXT_ELEMENT"):
  if elm.name == 'SiteName':
    elm.text = SiteName 
  elif elm.name == 'Address':
     elm.text = Address&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 00:26:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrate-script-tool-with-parameters-to-arcgis-pro/m-p/1014162#M25006</guid>
      <dc:creator>MarkBryant</dc:creator>
      <dc:date>2021-01-06T00:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Migrate script tool with parameters to ArcGIS Pro</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrate-script-tool-with-parameters-to-arcgis-pro/m-p/1014769#M25013</link>
      <description>&lt;P&gt;I'd recommend you run the&amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/analyzetoolsforpro.htm" target="_self"&gt;Analyze Tools for Pro&lt;/A&gt;&amp;nbsp;GP tool on your script to see what part of the Python script will need to be changed from 2.7 Python to 3.7.x Python.&amp;nbsp; The GP tool is available in ArcMap and ArcGIS Pro.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 18:26:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrate-script-tool-with-parameters-to-arcgis-pro/m-p/1014769#M25013</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2021-01-07T18:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Migrate script tool with parameters to ArcGIS Pro</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrate-script-tool-with-parameters-to-arcgis-pro/m-p/1099604#M25844</link>
      <description>&lt;P&gt;&lt;STRONG&gt;i have the same issues and want to convert the script from arcmap to arcgis pro&amp;nbsp;&lt;/STRONG&gt;&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;</description>
      <pubDate>Sat, 18 Sep 2021 10:25:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrate-script-tool-with-parameters-to-arcgis-pro/m-p/1099604#M25844</guid>
      <dc:creator>MahmoudHegazy</dc:creator>
      <dc:date>2021-09-18T10:25:05Z</dc:date>
    </item>
  </channel>
</rss>

