Select to view content in your preferred language

CalculateField Expression Not Working

332
2
Jump to solution
02-28-2025 09:32 AM
Labels (2)
MarkMcDill
New Contributor

I am new to ArcGIS and the ArcPY Module; recently I've run into an issue with ArcPY losing resolution to an object (a feature class) that I know exists.  Error: name '<variable name>' is not defined (where <variable name> is the object/feature class to which I'm referring).

The '<variable name>' can be accessed prior to the CalculateField execution in other ArcPY tools.

Also, the expression that I'm using in CalculateField was built and tested in both CalculateField ArcGIS Pro geoprocessing pane and in the python window in pro.

The feature class is created and then joined to a local feature class based on a couple conditions -- that join is successful; however, when attempting to create an expression of which part of the expression refers to the feature class, I get the error (name '<variable name>' is not defined) in the CalculateField tool

An alternate solution was to use UpdateCursor, but it states that it cannot update a joined table.

Any ideas?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
MarkMcDill
New Contributor

Cody

Shortly after posting this issue I tried a new route and it worked.  As stated, I'm new to ArcPy so I did not realize there is an arcpy.CalculateField class and an arcpy.CalculateField(plural) class.  Using arcpy.CalculateFieldsolved the issue

View solution in original post

2 Replies
CodyPatterson
MVP Regular Contributor

Hey @MarkMcDill 

Would it be possible to share a snippet of the code referenced along with a screenshot of the error maybe? We'd be able to get a nice look into how the program is interacting.

Cody

MarkMcDill
New Contributor

Cody

Shortly after posting this issue I tried a new route and it worked.  As stated, I'm new to ArcPy so I did not realize there is an arcpy.CalculateField class and an arcpy.CalculateField(plural) class.  Using arcpy.CalculateFieldsolved the issue