Select to view content in your preferred language

Field Calculator - how to get current feature class name?

2296
1
06-08-2016 01:46 PM
by Anonymous User
Not applicable

I'm writing a python pre-logic script for use in the field calculator.  One of my function calls needs to know the feature class name - e.g..

with arcpy.da.SearchCursor("LandUse", "Shape_Area") as cursor:

In this example, the Field Calculator has been launched as a right-click on a column of a attribute table of the LandUse feature class.  Rather than hard-wire the feature class name and then have to edit it each time I use the code snippet on a different FC, does arcpy have a method of determining and returning the feature class name for the current context of the field calculator?

Tags (2)
0 Kudos
1 Reply
DarrenWiens2
MVP Honored Contributor

I'll just come out and say it, "no" (unfortunately).

You can fairly easily make a script tool, though, in which your feature class or layer would be the only parameter. It's less work to fill in the parameter than to open the attribute table and copy/paste into the field calculator.