Skip to main content
added 423 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

My original answer appears below the double line. I am updating it because when I checked ArcGIS Pro 2.7.2 just now it looks like the functionality that you seek has been returned at that or an earlier version. It can be found on the ModelBuilder tab of the Ribbon under Export | Export To Python File.

enter image description here



The reasons for the removal of this functionality are given at What happened To Export Script Button In ArcGIS Pro? by dflater-esristaff:

The ability to export from ModelBuilder to a Python script was removed from ArcGIS Pro 1.1 because it did not match user expectations to provide a one-to-one export of your model to Python. The scripts generated by exported models were missing nested sub-models, and did not include iterators, feedback loops, and in-line variable substitution. Models with these components would require major changes that most people who use Export are not able to make themselves. There is currently no plan to add this capability back into ArcGIS Pro.

I ceased exporting ModelBuilder models in ArcMap to Python code the day I discovered Copy As Python Snippet because the exported code was far harder to understand and debug due to the way it named variables, lacked understanding of iterators, etc.

I think it is far easier to learn ArcPy in ArcGIS Pro by using Copy Python Command to copy the exact Python syntax needed to run the geoprocessing tool with the same parameter settings previously used, and then paste it into a script that you are writing.

Alternatively, if you want to quickly run your model using ArcPy, dflater-esristaff also describes a workaround of:

Start by building and saving a model, then create a new Python script file (which is just a text file with .py extension), then using a text editor or Python IDE add lines to the new script to import arcpy, import the toolbox containing your model, and finally run the model.

...

import arcpy
arcpy.ImportToolbox(r"c:\pathtotbx\Toolbox.tbx", "mytools")
arcpy.MyModel_mytools(r"c:\modelinputs\Data.gdb\InputFeatures")

The reasons for the removal of this functionality are given at What happened To Export Script Button In ArcGIS Pro? by dflater-esristaff:

The ability to export from ModelBuilder to a Python script was removed from ArcGIS Pro 1.1 because it did not match user expectations to provide a one-to-one export of your model to Python. The scripts generated by exported models were missing nested sub-models, and did not include iterators, feedback loops, and in-line variable substitution. Models with these components would require major changes that most people who use Export are not able to make themselves. There is currently no plan to add this capability back into ArcGIS Pro.

I ceased exporting ModelBuilder models in ArcMap to Python code the day I discovered Copy As Python Snippet because the exported code was far harder to understand and debug due to the way it named variables, lacked understanding of iterators, etc.

I think it is far easier to learn ArcPy in ArcGIS Pro by using Copy Python Command to copy the exact Python syntax needed to run the geoprocessing tool with the same parameter settings previously used, and then paste it into a script that you are writing.

Alternatively, if you want to quickly run your model using ArcPy, dflater-esristaff also describes a workaround of:

Start by building and saving a model, then create a new Python script file (which is just a text file with .py extension), then using a text editor or Python IDE add lines to the new script to import arcpy, import the toolbox containing your model, and finally run the model.

...

import arcpy
arcpy.ImportToolbox(r"c:\pathtotbx\Toolbox.tbx", "mytools")
arcpy.MyModel_mytools(r"c:\modelinputs\Data.gdb\InputFeatures")

My original answer appears below the double line. I am updating it because when I checked ArcGIS Pro 2.7.2 just now it looks like the functionality that you seek has been returned at that or an earlier version. It can be found on the ModelBuilder tab of the Ribbon under Export | Export To Python File.

enter image description here



The reasons for the removal of this functionality are given at What happened To Export Script Button In ArcGIS Pro? by dflater-esristaff:

The ability to export from ModelBuilder to a Python script was removed from ArcGIS Pro 1.1 because it did not match user expectations to provide a one-to-one export of your model to Python. The scripts generated by exported models were missing nested sub-models, and did not include iterators, feedback loops, and in-line variable substitution. Models with these components would require major changes that most people who use Export are not able to make themselves. There is currently no plan to add this capability back into ArcGIS Pro.

I ceased exporting ModelBuilder models in ArcMap to Python code the day I discovered Copy As Python Snippet because the exported code was far harder to understand and debug due to the way it named variables, lacked understanding of iterators, etc.

I think it is far easier to learn ArcPy in ArcGIS Pro by using Copy Python Command to copy the exact Python syntax needed to run the geoprocessing tool with the same parameter settings previously used, and then paste it into a script that you are writing.

Alternatively, if you want to quickly run your model using ArcPy, dflater-esristaff also describes a workaround of:

Start by building and saving a model, then create a new Python script file (which is just a text file with .py extension), then using a text editor or Python IDE add lines to the new script to import arcpy, import the toolbox containing your model, and finally run the model.

...

import arcpy
arcpy.ImportToolbox(r"c:\pathtotbx\Toolbox.tbx", "mytools")
arcpy.MyModel_mytools(r"c:\modelinputs\Data.gdb\InputFeatures")
added 6 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

The reasons for the removal of this functionality are given at What happened To Export Script Button In ArcGIS Pro? by dflater-esristaff:

The ability to export from ModelBuilder to a Python script was removed from ArcGIS Pro 1.1 because it did not match user expectations to provide a one-to-one export of your model to Python. The scripts generated by exported models were missing nested sub-models, and did not include iterators, feedback loops, and in-line variable substitution. Models with these components would require major changes that most people who use Export are not able to make themselves. There is currently no plan to add this capability back into ArcGIS Pro.

I ceased exporting ModelBuilder models in ArcMap to Python code the day I discovered Copy As Python Snippet because the exported code was far harder to understand and debug due to the way it named variables, lacked understanding of iterators, etc.

I think it is far easier to learn ArcPy in ArcGIS Pro by using Copy Python Command to copy the exact Python syntax needed to run the geoprocessing tool with the same parameter settings previously used, and then paste it into a script that you are writing.

HoweverAlternatively, if you want to quickly run your model using ArcPy, dflater-esristaff also describes a workaround of:

Start by building and saving a model, then create a new Python script file (which is just a text file with .py extension), then using a text editor or Python IDE add lines to the new script to import arcpy, import the toolbox containing your model, and finally run the model.

...

import arcpy
arcpy.ImportToolbox(r"c:\pathtotbx\Toolbox.tbx", "mytools")
arcpy.MyModel_mytools(r"c:\modelinputs\Data.gdb\InputFeatures")

The reasons for the removal of this functionality are given at What happened To Export Script Button In ArcGIS Pro? by dflater-esristaff:

The ability to export from ModelBuilder to a Python script was removed from ArcGIS Pro 1.1 because it did not match user expectations to provide a one-to-one export of your model to Python. The scripts generated by exported models were missing nested sub-models, and did not include iterators, feedback loops, and in-line variable substitution. Models with these components would require major changes that most people who use Export are not able to make themselves. There is currently no plan to add this capability back into ArcGIS Pro.

I ceased exporting ModelBuilder models in ArcMap to Python code the day I discovered Copy As Python Snippet because the exported code was far harder to understand and debug due to the way it named variables, lacked understanding of iterators, etc.

I think it is far easier to learn ArcPy in ArcGIS Pro by using Copy Python Command to copy the exact Python syntax needed to run the geoprocessing tool with the same parameter settings previously used, and then paste it into a script that you are writing.

However, if you want to quickly run your model using ArcPy, dflater-esristaff also describes a workaround of:

Start by building and saving a model, then create a new Python script file (which is just a text file with .py extension), then using a text editor or Python IDE add lines to the new script to import arcpy, import the toolbox containing your model, and finally run the model.

...

import arcpy
arcpy.ImportToolbox(r"c:\pathtotbx\Toolbox.tbx", "mytools")
arcpy.MyModel_mytools(r"c:\modelinputs\Data.gdb\InputFeatures")

The reasons for the removal of this functionality are given at What happened To Export Script Button In ArcGIS Pro? by dflater-esristaff:

The ability to export from ModelBuilder to a Python script was removed from ArcGIS Pro 1.1 because it did not match user expectations to provide a one-to-one export of your model to Python. The scripts generated by exported models were missing nested sub-models, and did not include iterators, feedback loops, and in-line variable substitution. Models with these components would require major changes that most people who use Export are not able to make themselves. There is currently no plan to add this capability back into ArcGIS Pro.

I ceased exporting ModelBuilder models in ArcMap to Python code the day I discovered Copy As Python Snippet because the exported code was far harder to understand and debug due to the way it named variables, lacked understanding of iterators, etc.

I think it is far easier to learn ArcPy in ArcGIS Pro by using Copy Python Command to copy the exact Python syntax needed to run the geoprocessing tool with the same parameter settings previously used, and then paste it into a script that you are writing.

Alternatively, if you want to quickly run your model using ArcPy, dflater-esristaff also describes a workaround of:

Start by building and saving a model, then create a new Python script file (which is just a text file with .py extension), then using a text editor or Python IDE add lines to the new script to import arcpy, import the toolbox containing your model, and finally run the model.

...

import arcpy
arcpy.ImportToolbox(r"c:\pathtotbx\Toolbox.tbx", "mytools")
arcpy.MyModel_mytools(r"c:\modelinputs\Data.gdb\InputFeatures")
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

The reasons for the removal of this functionality are given at What happened To Export Script Button In ArcGIS Pro? by dflater-esristaff:

The ability to export from ModelBuilder to a Python script was removed from ArcGIS Pro 1.1 because it did not match user expectations to provide a one-to-one export of your model to Python. The scripts generated by exported models were missing nested sub-models, and did not include iterators, feedback loops, and in-line variable substitution. Models with these components would require major changes that most people who use Export are not able to make themselves. There is currently no plan to add this capability back into ArcGIS Pro.

I ceased exporting ModelBuilder models in ArcMap to Python code the day I discovered Copy As Python Snippet because the exported code was far harder to understand and debug due to the way it named variables, lacked understanding of iterators, etc.

I think it is far easier to learn ArcPy in ArcGIS Pro by using Copy Python Command to copy the exact Python syntax needed to run the geoprocessing tool with the same parameter settings previously used, and then paste it into a script that you are writing.

However, if you want to quickly run your model using ArcPy, dflater-esristaff also describes a workaround of:

Start by building and saving a model, then create a new Python script file (which is just a text file with .py extension), then using a text editor or Python IDE add lines to the new script to import arcpy, import the toolbox containing your model, and finally run the model.

...

import arcpy
arcpy.ImportToolbox(r"c:\pathtotbx\Toolbox.tbx", "mytools")
arcpy.MyModel_mytools(r"c:\modelinputs\Data.gdb\InputFeatures")