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

Hornbydd
44.9k5 gold badges42 silver badges84 bronze badges
asked Jan 6, 2022 at 17:02

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.

answered Jan 6, 2022 at 17:12
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.