1

I am putting together a model that will look at a field called "gridcode" that has values 1, 2, and 3. Depending on which value it has, it will calculate another field called Class_Name2. The values in Class_Name2 will depend on inline variable substitution because I want to use this for datasets that may have different values.

However, when I run the model it says the class value I typed in is not defined, even though I am defining them with a model parameter.

Here is my model, where Class 1, Class 2, Class 3, are set as strings and preconditions to the Field Calculator. These values will be typed in and substituted in the model when I run the tool in the second screenshot. The substitution is defined as %Class 1%, %Class 2%, and %Class 3%, respectfully.

My problem is the third screenshot. I am not sure what else I should add so the model clearly sees that it is text. I tried to add '"' + to either side of the %Class 1% but that did not help. Neither did str().

Any ideas on how to improve this model?

enter image description here

enter image description here

enter image description here

1 Answer 1

2

In the Calculate Field code block you need to enclose your substitution in double quotes so the return line should be

return "%Class 1%"

repeat for the others.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.