<?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: arcpy  scripting error question in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785972#M167</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep... That's the 'other' thread...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Oct 2018 20:08:58 GMT</pubDate>
    <dc:creator>JoeBorgione</dc:creator>
    <dc:date>2018-10-17T20:08:58Z</dc:date>
    <item>
      <title>arcpy  scripting error question</title>
      <link>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785967#M162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having some issues with creating a&amp;nbsp; script to count stairwells from a stair shapefile. I have two shapefiles one being stairs and another one being&amp;nbsp; stairwell.&amp;nbsp;&amp;nbsp; I&amp;nbsp; was instructed to use this&amp;nbsp; code&amp;nbsp; and&amp;nbsp; make&amp;nbsp; a simple&amp;nbsp; script. i am not used to working with python so if you can help that would be much appreciated. code is pasted below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def createInternalParallelLines():&lt;BR /&gt; # import libraries&lt;BR /&gt; import arcpy&lt;/P&gt;&lt;P&gt;# set input/output parameters&lt;BR /&gt; polyFC = arcpy.GetParameterAsText(0) # input polygons&lt;BR /&gt; outParallel = arcpy.GetParameterAsText(1) # output parallel lines&lt;BR /&gt; lineSpacing = arcpy.GetParameterAsText(2) # line spacing&lt;BR /&gt; buffDist = arcpy.GetParameterAsText(3) # inner buffer distance&lt;/P&gt;&lt;P&gt;# parse numbers from parameters&lt;BR /&gt; lineSpaceNum = float(lineSpacing.split(' ')[0])&lt;BR /&gt; buffNum = float(buffDist.split(' ')[0])&lt;/P&gt;&lt;P&gt;# establish spatial reference&lt;BR /&gt; desc = arcpy.Describe(polyFC)&lt;BR /&gt; SR = desc.spatialReference&lt;/P&gt;&lt;P&gt;# set overwrite environment&lt;BR /&gt; arcpy.env.overwriteOutput = True&lt;BR /&gt; arcpy.env.outputCoordinateSystem = SR&lt;/P&gt;&lt;P&gt;parallels = []&lt;BR /&gt; # create hull rectangle to establish a rotated area of interest&lt;BR /&gt; coordSplit = row[0].hullRectangle.split(' ')&lt;/P&gt;&lt;P&gt;# collect corner coordinates&lt;BR /&gt; coordList = arcpy.Array([arcpy.Point(coordSplit[0],coordSplit[1]),arcpy.Point(coordSplit[2],coordSplit[3]),arcpy.Point(coordSplit[4],coordSplit[5]),arcpy.Point(coordSplit[6],coordSplit[7]),arcpy.Point(coordSplit[0],coordSplit[1])])&lt;/P&gt;&lt;P&gt;# create lines from hull rectangle&lt;BR /&gt; currentLines = []&lt;BR /&gt; for pointNum in range(0,4):&lt;BR /&gt; arcpy.Array([coordList.getObject(pointNum),coordList.getObject(pointNum+1)])&lt;BR /&gt; hullRecLine = arcpy.Polyline(arcpy.A&lt;BR /&gt; # loop through each input shape&lt;BR /&gt; for row in arcpy.da.SearchCursor(polyFC, ["SHAPE@"], spatial_reference=SR):&lt;/P&gt;&lt;P&gt;# create inner buffer&lt;BR /&gt; polyBuff = row[0].buffer(buffNum * -1)&lt;BR /&gt;rray([coordList.getObject(pointNum),coordList.getObject(pointNum+1)]))&lt;BR /&gt; currentLines.append(hullRecLine)&lt;/P&gt;&lt;P&gt;# compare first and second line to determine if first line is short or long&lt;BR /&gt; firstLong = 0&lt;BR /&gt; if currentLines[0].length &amp;lt; currentLines[1].length:&lt;BR /&gt; firstLong = 1&lt;/P&gt;&lt;P&gt;# calculate number of points needed along short axis&lt;BR /&gt; numPoints = int(math.floor(currentLines[firstLong].length/lineSpaceNum))&lt;/P&gt;&lt;P&gt;# create and join points to create parallel lines&lt;BR /&gt; for point in range(1,numPoints+1):&lt;BR /&gt; shortPoint1 = currentLines[firstLong].positionAlongLine(lineSpaceNum*point)&lt;BR /&gt; shortPoint2 = currentLines[firstLong + 2].positionAlongLine(currentLines[firstLong + 2].length - (lineSpaceNum*point))&lt;BR /&gt; parallel = arcpy.Polyline(arcpy.Array([shortPoint1.centroid,shortPoint2.centroid]), SR)&lt;/P&gt;&lt;P&gt;# intersect parallel lines with buffer&lt;BR /&gt; parallelBuff = parallel.intersect(polyBuff,2)&lt;BR /&gt; parallels.append(parallelBuff)&lt;/P&gt;&lt;P&gt;# write geometries to disk&lt;BR /&gt; arcpy.CopyFeatures_management(parallels, outParallel)&lt;/P&gt;&lt;P&gt;# add to map&lt;BR /&gt; mxd = arcpy.mapping.MapDocument("CURRENT")&lt;BR /&gt; dataFrame = arcpy.mapping.ListDataFrames(mxd, "*")[0]&lt;BR /&gt; addLayer = arcpy.mapping.Layer(outParallel)&lt;BR /&gt; arcpy.mapping.AddLayer(dataFrame, addLayer)&lt;/P&gt;&lt;P&gt;del row&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 19:09:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785967#M162</guid>
      <dc:creator>devarsimajumder2</dc:creator>
      <dc:date>2018-10-17T19:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy  scripting error question</title>
      <link>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785968#M163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should&amp;nbsp;really use the syntax highlighter when posting code.&amp;nbsp; It makes it so much easier to read.&amp;nbsp; (Click on the three dots (expand tool bar); choose More; pull down to syntax highligher; select Python....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first thing I see is your lack of indentation for your def().&amp;nbsp; Everything inside the def() needs to be indented:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;myFunction&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; list commands
&amp;nbsp; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; desired order
&amp;nbsp; &lt;SPAN class="operator token"&gt;and&lt;/SPAN&gt; indent accordingly

other commands outside the
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; don't get indented‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited moments later:&amp;nbsp; I just copied your code into SPyder and there are tons of problems with it aside from def(): indentation.&amp;nbsp; I see missing closing parenthesis, extra parenthesis,&amp;nbsp; &amp;nbsp;ill structured for loopsetc etc...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:57:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785968#M163</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-12T08:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy  scripting error question</title>
      <link>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785969#M164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp; to get you going on the format issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error message if any and details of the inputs would help (ie location and types of inputs)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 19:47:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785969#M164</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-10-17T19:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy  scripting error question</title>
      <link>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785970#M165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Having read your other thread for the same subject, you might want to take a look at:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.codecademy.com/learn/learn-python" title="https://www.codecademy.com/learn/learn-python"&gt;https://www.codecademy.com/learn/learn-python&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.learnpython.org/" title="https://www.learnpython.org/"&gt;Learn Python - Free Interactive Python Tutorial&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.python.org/about/gettingstarted/" title="https://www.python.org/about/gettingstarted/"&gt;Python For Beginners | Python.org&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To name a few....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 19:48:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785970#M165</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2018-10-17T19:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy  scripting error question</title>
      <link>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785971#M166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The loop widens&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/222975-python-script-not-working"&gt;https://community.esri.com/thread/222975-python-script-not-working&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 19:57:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785971#M166</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-10-17T19:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy  scripting error question</title>
      <link>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785972#M167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep... That's the 'other' thread...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 20:08:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/arcpy-scripting-error-question/m-p/785972#M167</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2018-10-17T20:08:58Z</dc:date>
    </item>
  </channel>
</rss>

