Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

flipping lines with ArcView (Basic)

$
0
0
Hi there.

So I used to have a VB script that could flip multiple selected lines, using an ArcView licence.

Of course, now we can do this with an ArcEditor (Standard) licence via Python but, alas, I have users that do this kind of work that do NOT have that level of licencing.

I did find this code snippet that claims to flip lines for a Basic licence, but I'm having difficulty running it.

Does anyone have a better way to flip multiple selected lines with a Basic licence? or can anyone see the errors in the the below script?

Code:

import math,sys
import arcgisscripting
gp = arcgisscripting.create(9.3)


gp.overwriteoutput=1

try:


    filename = gp.getparameterastext(0)

    cur = gp.UpdateCursor(filename)

    npnt=gp.createobject("Point")
 
    row=cur.next()

    while row:
     
        feat=row.shape
        PointCount = feat.PointCount
        i=0
        xlist=[]
        ylist=[]
        print 'do'
        while i < feat.PartCount:
            ptArray = feat.GetPart(i)
            ptArray.Reset
            pnt=ptArray.Next()
            while pnt:
                xlist.append(pnt.x)
                ylist.append(pnt.y)
                pnt=ptArray.next()
         
            xlist.reverse()
            ylist.reverse()

            ptArray.removeall()
            for j in range(len(xlist)):
                npnt.x=xlist[j]
                npnt.y=ylist[j]
                ptArray.add(npnt)

            row.shape=ptArray
            cur.updateRow(row)
                     
            i=i+1 
        print 'ok'     
        row=cur.next()
     
    del row,cur,pnt,npnt

except:
    gp.adderror('error')


Viewing all articles
Browse latest Browse all 2485

Trending Articles