Friday, 22 November 2019

User defined parameter within code block of field calculator - Modelbuilder - ArcGIS - Python


I am using Reclass within a Code Block in Field Calculator in a Model to calculate field values for a variable based on several other fields.


Using reclass is much quicker than select and then using Calculate Field.



The example below works fine.


enter image description here


This is a simple example of the way i am using this. The typical use references many more fields.


My question is this.


Instead of a hard coded and fixed value i wish to use a user generated Parameter.Therefore I set a new variable named "Buildx", set this as a Parameter. Then i replaced the value of "30" in the code block with %Buildx%. This should work as in line variable substitution, however i get the 99999 error code.


enter image description here


I tried setting the stand alone variable Parameter as either Any Value or as a Long Integer, but neither worked.


I'd be grateful of any advice or ideas.


Error message below - the stand alone variable has been coded as 30, so it appears as 30 in the error message, but results in an error.


enter image description here




Answer



It's Python code but your Expression Type in the second screenshot is VB ;)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...