<?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 How to simply add a layer for a GPFeatureRecordSetLayer parameter in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-simply-add-a-layer-for-a/m-p/568419#M44523</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to have an interactive Input layer for a tool in a python Toolbox. I'm only interested in the geometry the user specified, other attributes don't matter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I have now:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;    def getParameterInfo(self):
        p1 = arcpy.Parameter(name = "point", displayName = "bla", datatype = "GPFeatureRecordSetLayer", parameterType = "Required", direction = "Input")
        # get target layer from MapDocument and create a temporary copy
        mxd = arcpy.mapping.MapDocument("CURRENT")
        layer = arcpy.mapping.ListLayers(mxd, "layer_name")
        temp_path = "Path:\\to\\layer.lyr"
        layer.saveACopy(temp_path)
        # assign the layer to p1
        p1.value = temp_path
        return [p1]‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;That works, but it's very cumbersome (it's slow, there has to be a layer with the geometry I want in the map, I can't hardcode the layer path, because I can't be sure the user has write permissions (and I can't save it to in_memory), and I would have to delete the layer to avoid cluttering random directories).&lt;/P&gt;&lt;P&gt;Is it possible to create a point (or line or whatever) layer file on the fly? Or can I somehow save a layer with the python modules and reference it in the script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:29:11 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2021-12-12T00:29:11Z</dc:date>
    <item>
      <title>How to simply add a layer for a GPFeatureRecordSetLayer parameter</title>
      <link>https://community.esri.com/t5/python-questions/how-to-simply-add-a-layer-for-a/m-p/568419#M44523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to have an interactive Input layer for a tool in a python Toolbox. I'm only interested in the geometry the user specified, other attributes don't matter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I have now:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;    def getParameterInfo(self):
        p1 = arcpy.Parameter(name = "point", displayName = "bla", datatype = "GPFeatureRecordSetLayer", parameterType = "Required", direction = "Input")
        # get target layer from MapDocument and create a temporary copy
        mxd = arcpy.mapping.MapDocument("CURRENT")
        layer = arcpy.mapping.ListLayers(mxd, "layer_name")
        temp_path = "Path:\\to\\layer.lyr"
        layer.saveACopy(temp_path)
        # assign the layer to p1
        p1.value = temp_path
        return [p1]‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;That works, but it's very cumbersome (it's slow, there has to be a layer with the geometry I want in the map, I can't hardcode the layer path, because I can't be sure the user has write permissions (and I can't save it to in_memory), and I would have to delete the layer to avoid cluttering random directories).&lt;/P&gt;&lt;P&gt;Is it possible to create a point (or line or whatever) layer file on the fly? Or can I somehow save a layer with the python modules and reference it in the script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:29:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-simply-add-a-layer-for-a/m-p/568419#M44523</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-12-12T00:29:11Z</dc:date>
    </item>
  </channel>
</rss>

