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

If else statement

$
0
0
I am modifying a script suggested in a prior thread. http://forums.arcgis.com/threads/902...ght=jsmith0705

I want to be able to select a line, determine if the ARCLENGTH field has a value greater than zero, return that value if greater than zero, if not return the value from the Shape_Length field.

The script runs with no errors or results.

Code:

import arcpy

mxd = arcpy.mapping.MapDocument ("CURRENT")
df = arcpy.mapping.ListDataFrames (mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, "Lot_Lines", df)[0]

for lyr in arcpy.mapping.ListLayers(mxd):
        tlyr = lyr
        dsc = arcpy.Describe(tlyr)
        sel_set = dsc.FIDSet
        if dsc.shapeType == "Line":
                if len(sel_set) > 0: #If ARCLENGTH value > 0     
                        arcpy.AddMessage(str(ARCLENGTH)) #Return ARCLENGTH value
                else:
                        arcpy.AddMessage(str(Shape_Length)) #Return Shape_Length value


Viewing all articles
Browse latest Browse all 2485

Latest Images

Trending Articles



Latest Images