Select to view content in your preferred language

Copy Python Command Incorrectly Populates Parameters

114
1
10-31-2024 04:54 AM
Labels (1)
simskr
by
New Contributor

Hello,

I created a fishnet in ArcGIS Pro using the parameters shown in Screenshot 1.

Screenshot 2024-10-31 124702.png

When I try to convert the operation to a Python script using the "Copy Python Command" tool, it generates the following code:

 

 

arcpy.management.CreateFishnet(
    out_feature_class=r"Path_to_Fishnet",
    origin_coord=0,
    y_axis_coord=1,
    cell_width=1,
    cell_height=1,
    number_rows=10,
    number_columns=15,
    corner_coord=None,
    labels="LABELS",
    template="DEFAULT",
    geometry_type="POLYLINE"
)

 

 

However, this command does not work and results in the following error:

 

 

arcgisscripting.ExecuteError: ERROR 000622: Failed to execute (Create Fishnet). Parameters are not valid.
ERROR 000628: Cannot set input into parameter origin_coord.

 

 

Could you please look into this issue?

 

version is ArcGIS Pro 3.3.2

0 Kudos
1 Reply
RichardHowe
Frequent Contributor

First up, just in case...you have to actually replace the r"Path_to_Fishnet" with an output path of where you want to create the file. Either using a variable that you define elsewhere or pasting an explicit filepath in between the speech marks.

Secondly, if you look at the sample script for this tool (on the help page) then the format for both the origin coordinate and y axis coordinate is a point (not a number). So the tool is expecting a string separated by a space. I believe the input (based on your toolbox inputs) should look as below:

arcpy.management.CreateFishnet(
    out_feature_class=r"Path_to_Fishnet",
    origin_coord="0 0",
    y_axis_coord="0 1",
    cell_width=1,
    cell_height=1,
    number_rows=10,
    number_columns=15,
    corner_coord=None,
    labels="LABELS",
    template="DEFAULT",
    geometry_type="POLYLINE"
)

 
Hopefully that gets you to where you need to be. But I accept the copy python command tool isn't doing  what it should - spoiler alert - it often doesn't! 😂

0 Kudos