<?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: Python Toolbox: Issue saving an edited input parameter as a layer file in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-toolbox-issue-saving-an-edited-input/m-p/1175974#M64597</link>
    <description>&lt;P&gt;Does it appear if you tell the lyr to save to a folder instead of a GDB? I think lyr files are only visible in folders.&lt;/P&gt;&lt;P&gt;I'm also not 100% sure a lyr is what you want in this case; it doesn't alter any data so much as tell it how to present itself.&lt;/P&gt;&lt;P&gt;That is, you're not making any permanent changes here. It seems like your original idea of deleting rows would be better; it'll make sure the changes you want are actually permanent, so you don't accidentally click the wrong button and have the entire grid appear all over again.&lt;/P&gt;</description>
    <pubDate>Fri, 20 May 2022 16:31:02 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2022-05-20T16:31:02Z</dc:date>
    <item>
      <title>Python Toolbox: Issue saving an edited input parameter as a layer file</title>
      <link>https://community.esri.com/t5/python-questions/python-toolbox-issue-saving-an-edited-input/m-p/1175888#M64595</link>
      <description>&lt;P&gt;Hi there. This is a follow-on question from my previous post. If you would like more context, please visit the post here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-questions/python-toolbox-issues-using-arcpy-select-by/m-p/1175370#M64581" target="_blank"&gt;https://community.esri.com/t5/python-questions/python-toolbox-issues-using-arcpy-select-by/m-p/1175370#M64581&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have previously created a python toolbox script that will create a fishnet and select the cells that intersect a boundary defined by a parameter. Cells that do not intersect the boundary are deleted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DPG_0-1653044870961.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/41810i3F9283A95D851D49/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DPG_0-1653044870961.png" alt="DPG_0-1653044870961.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I now want to change the script so that the fishnet is not created in the script - instead it is defined as a parameter. Following this, I want the script to select the cells that intersect the boundary and then save them as a new layer file. param0 is defined as the boundary and param1 as the fishnet. The script looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# -*- coding: utf-8 -*-

import arcpy


class Toolbox(object):
    def __init__(self):

        self.label = "Toolbox"
        self.alias = "toolbox"

        # List of tool classes associated with this toolbox
        self.tools = [Tool]


class Tool(object):
    def __init__(self):

        self.label = "Tool"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):

        # Param 0 = UK Boundary
        param0 = arcpy.Parameter(
        displayName="Input Feature Class",
        name="Parameter0",
        datatype="GPFeatureLayer",
        parameterType="Required",
        direction="Input")
        param0.filter.list=["POLYGON"]

        # Param 1 = Fishnet
        param1 = arcpy.Parameter(
        displayName="GRID",
        name="Parameter1",
        datatype="GPFeatureLayer",
        parameterType="Required",
        direction="Input")

        params = [param0,param1]
        
        return params

    def isLicensed(self):

        return True

    def updateParameters(self, parameters):

        return

    def updateMessages(self, parameters):

        return

    def execute(self, parameters, messages):

        # Overwrite existing file of the same name
        arcpy.env.overwriteOutput = True

        # Reference Parameters
        input1 = parameters[0].valueAsText
        inputgrid1 = parameters[1].valueAsText

        # Convert inputgrid1 to feature class

        arcpy.management.MakeFeatureLayer(inputgrid1,"inputgrid1_lyr")

        # Select by Location

        arcpy.management.SelectLayerByLocation("inputgrid1_lyr", "INTERSECT", input1, None, "NEW_SELECTION", "NOT_INVERT")

        # Save to layer file

        arcpy.management.SaveToLayerFile(inputgrid1,"NewGrid.lyr")



        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Upon completion of the script, I receive no errors. However, no new layer file (NewGrid.lyr) appears in my geodatabase. I have a feeling that the solution here is simple - so apologies in advance for my poor understanding of Python toolboxes. Is anybody able to offer any guidance?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 11:15:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-toolbox-issue-saving-an-edited-input/m-p/1175888#M64595</guid>
      <dc:creator>DPG</dc:creator>
      <dc:date>2022-05-20T11:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Python Toolbox: Issue saving an edited input parameter as a layer file</title>
      <link>https://community.esri.com/t5/python-questions/python-toolbox-issue-saving-an-edited-input/m-p/1175974#M64597</link>
      <description>&lt;P&gt;Does it appear if you tell the lyr to save to a folder instead of a GDB? I think lyr files are only visible in folders.&lt;/P&gt;&lt;P&gt;I'm also not 100% sure a lyr is what you want in this case; it doesn't alter any data so much as tell it how to present itself.&lt;/P&gt;&lt;P&gt;That is, you're not making any permanent changes here. It seems like your original idea of deleting rows would be better; it'll make sure the changes you want are actually permanent, so you don't accidentally click the wrong button and have the entire grid appear all over again.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 16:31:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-toolbox-issue-saving-an-edited-input/m-p/1175974#M64597</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2022-05-20T16:31:02Z</dc:date>
    </item>
  </channel>
</rss>

