Only add ArcLength when it is greater than '0'. Otherwise, the script should return shapeLength values and add those together.
Then just use the code as written in my post before that. Here is how to make the message only report the totals if they are above 0.for lyr in arcpy.mapping.ListLayers(mxd):
dsc = arcpy.Describe(lyr)
sel_set = dsc.fidSet.replace(";",",")
if dsc.shapeType == "Polyline" and dsc.fidSet != "":
cursor = arcpy.da.SearchCursor(lyr, ["OID@", "ARCLENGTH", "Shape_Length"], "OBJECTID IN (" + sel_set + ")")
arcLengthTot = 0
shapeLengthTot = 0
for row in cursor:
arcLength = row[1]
shapeLength = row[2]
if arcLength > '0':
arcLengthTot += float(arcLength)
arcpy.AddMessage("ArcLength = " + arcLength)
else:
shapeLengthTot += shapeLength
arcpy.AddMessage("ShapeLength = " + str(shapeLength))
if arcLengthTot > 0:
arcpy.AddMessage("ArcLengthTot = " + str(arcLengthTot))
if shapeLengthTot > 0:
arcpy.AddMessage("ShapeLengthTot = " + str(shapeLengthTot))
del row
del cursor
Both totals messages could print for a given selection is you selected a mix of the two kinds of arcs/shapes as a group.You could now optionally comment out the individual reported lengths if you want just the totals or leave both individual segment and totals messages. For a single feature the messages would print two times and repeat the same number unless some more logic is added about the sel_set count.