<?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: Issue with Geometry in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/issue-with-geometry/m-p/1008513#M59248</link>
    <description>&lt;P&gt;I got this working. It seems the problem was in the parameter definition:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;shapesUsedFromLayer = arcpy.Parameter(
            displayName="Selected Shape(s) Will Be Used From This Layer",
            name="shapesUsedFromLayer",
            datatype="GPFeatureLayer", #"GPString",
            parameterType="Required",
            direction="Input")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had the parameter as GPString instead of GPFeatureLayer. I also removed references to inLayer and just used selLyr (from the parameter).&lt;/P&gt;</description>
    <pubDate>Thu, 10 Dec 2020 15:47:23 GMT</pubDate>
    <dc:creator>ChrisHolmes</dc:creator>
    <dc:date>2020-12-10T15:47:23Z</dc:date>
    <item>
      <title>Issue with Geometry</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-geometry/m-p/1005765#M59174</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have a procedure which takes a selected shape(s) from a layer and creates a copy of the shape in a different feature class. This procedure worked fine in desktop 10.5 and I am now trying to modify it to use in Pro 2.6.2.&lt;/P&gt;&lt;P&gt;The code works fine and it copies the shape into the other feature class but what isn't working is that the parcel which I copied the first time, continues to be copied in subsequent tests (even though I'm selecting different parcels).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a picture of the layer that the parcel to be copied is selected from. I have done numerous tests, each one selecting a different parcel.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisHolmes_0-1606798001121.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/1226i42FF27164DABC8AA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisHolmes_0-1606798001121.png" alt="ChrisHolmes_0-1606798001121.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Below is a picture of the feature class where the shapes are copied to. All of the records in the attribute table have the same parcel location (even though I selected different parcels above).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisHolmes_1-1606798133417.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/1227i22BBB1B9F5500AD4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisHolmes_1-1606798133417.png" alt="ChrisHolmes_1-1606798133417.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def CreateShapes(item, mapType, selLyr, dType, dbPath, proj, mapName, luCode=None):

    arcpy.env.overwriteOutput = True

    aprx = arcpy.mp.ArcGISProject(proj)
    m = aprx.listMaps(mapName)[0]
    inLayer = m.listLayers(selLyr)[0]

    #Get a count of how many shapes are selected
    resultSelShapes = arcpy.GetCount_management(inLayer)
    countSelShapes = int(resultSelShapes.getOutput(0))
    arcpy.AddMessage('Number of rows in inLayer: {}'.format(str(countSelShapes)))

    #create in_memory feature class
    tempFc = 'in_memory/tempFc'
    arcpy.CreateFeatureclass_management('in_memory','tempFc','POLYGON')
    if dType != 'NotRequired':
        #dissolve shapes
        arcpy.Dissolve_management(in_features=inLayer, out_feature_class=tempFc,
                                  multi_part=dType, unsplit_lines="DISSOLVE_LINES")

    #Get a count of how many shapes are in the post dissolve in memory feature class
    resultTempFc = arcpy.GetCount_management(tempFc)
    countTempFc = int(resultTempFc.getOutput(0))
    arcpy.AddMessage('Number of rows in tempFc: {}'.format(str(countTempFc)))

    polyGeom = []
    with arcpy.da.SearchCursor(in_table=tempFc, field_names='SHAPE@') as sCur:
        for row in sCur:
            polyGeom.append(row[0])
            arcpy.AddMessage('polyGeom.append(row[0]): {}'.format(row[0]))

    del sCur

    if mapType == 'Land Use Amendment':
        with arcpy.da.InsertCursor(in_table=dbPath + r'\PEYTO.PLANNING.PLAN_SITE_MNT',
                                                field_names=['APPLICATION_TYPE','ITEM','IS_VALID','SHAPE@']) as iCur:
            for poly in polyGeom:
                iCur.insertRow((mapType,item,'Y',poly))
        del iCur
        with arcpy.da.InsertCursor(in_table=dbPath + r'\PEYTO.PLANNING.PLAN_LU_BOUNDARY_MNT',
                                                field_names=['ITEM','STATUS','LU_CODE','IS_VALID','SHAPE@']) as iCur2:
            for poly in polyGeom:
                iCur2.insertRow((item,'PENDING',luCode,'Y',poly))
        del iCur2
        arcpy.AddMessage('Create Shapes procedure passed.')
        return True
    else:
        with arcpy.da.InsertCursor(in_table=dbPath + r'\PEYTO.PLANNING.PLAN_SITE_MNT',
                                                field_names=['APPLICATION_TYPE','ITEM','IS_VALID','SHAPE@']) as iCur:
            for poly in polyGeom:
                iCur.insertRow((mapType,item,'Y',poly))
        del iCur&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any ideas as to why the parcel being selected isn't the one being inserted into the other feature class.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2020 04:56:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-geometry/m-p/1005765#M59174</guid>
      <dc:creator>ChrisHolmes</dc:creator>
      <dc:date>2020-12-01T04:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Geometry</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-geometry/m-p/1005889#M59175</link>
      <description>&lt;P&gt;My guess the issue is this line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(in_table=tempFc, field_names='SHAPE@') as sCur:&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It appears you are making a selection on a layer and want that selection to be honored.&amp;nbsp; Unfortunately, your code is passing a data set and not a layer (even though something seems odd as well with how you are creating the temporary feature class).&amp;nbsp; Data sets don't contain selections, layers and table views do.&lt;/P&gt;&lt;P&gt;Also, in Pro, use the "memory" workspace and not "in-memory".&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2020 16:27:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-geometry/m-p/1005889#M59175</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-12-01T16:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Geometry</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-geometry/m-p/1005957#M59180</link>
      <description>&lt;P&gt;Thanks. I'll dig into this some more and update. Thanks for the tip on using 'memory' too.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2020 19:32:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-geometry/m-p/1005957#M59180</guid>
      <dc:creator>ChrisHolmes</dc:creator>
      <dc:date>2020-12-01T19:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Geometry</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-geometry/m-p/1008513#M59248</link>
      <description>&lt;P&gt;I got this working. It seems the problem was in the parameter definition:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;shapesUsedFromLayer = arcpy.Parameter(
            displayName="Selected Shape(s) Will Be Used From This Layer",
            name="shapesUsedFromLayer",
            datatype="GPFeatureLayer", #"GPString",
            parameterType="Required",
            direction="Input")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had the parameter as GPString instead of GPFeatureLayer. I also removed references to inLayer and just used selLyr (from the parameter).&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 15:47:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-geometry/m-p/1008513#M59248</guid>
      <dc:creator>ChrisHolmes</dc:creator>
      <dc:date>2020-12-10T15:47:23Z</dc:date>
    </item>
  </channel>
</rss>

