I like field calculator and use it often, however found something very disturbing today when attempted to do this on a table of 3D feature class.
def abc(shp,id): return shp.length
abc( !Shape!, !UNIQID!)
Executing: CalculateField LINES L abc( !Shape!, !UNIQID! ) PYTHON_9.3 "def abc(shp,id):\n return shp.length" Start Time: Mon Sep 12 12:30:28 2016 ERROR 000539: Error running expression: abc( GPVARIANTOBJECT0, L1 ) Traceback (most recent call last): File "<expression>", line 1, in <module> NameError: name 'L1' is not defined
On this table:
The same expression works fine on 2d features. Moreover if I remove second argument and run it as:
def abc(shp): return shp.length #---------------------- abc (!Shape!)
It also works as expected on table with 3D shapes.
So adding another variable to list of arguments results in a crush.
Somebody else can confirm this odd behaviour please.
I am working with 10.3.1 and it is happening only with second argument being text, numeric work fine.
I found a workaround by swapping arguments: abc(!UNIQID!,!Shape!)
UPDATE after @Midavalo comment:
Yes the same odd behaviour on 2D shapes