Error When Running Calculate Value

2243
27
08-31-2016 03:21 PM
ChrisHolmes
Occasional Contributor III

Hello Everyone,

I have a model which runs the calculate value tool:

The code in the tool is:

When the model runs the following errors are displayed:

I'm not sure what the errors are related to. What's strange is that the code does seem to execute: it displays the extent of the site_polygon layer, sets the scale to 1:4000, then creates the JPG file.

Any insights appreciated. Thanks!

Tags (2)
0 Kudos
27 Replies
DanPatterson_Retired
MVP Emeritus

return 'true'   perhaps   return True

boolean is not a string

XanderBakker
Esri Esteemed Contributor

Just wondering why you would want to use the ModelBuilder for this. It would be a lot more stable if you would create a script (and if necessary a tool from the script) to do this. 

ChrisHolmes
Occasional Contributor III

Actually, that would be my preference. I just haven't figured out yet how to pass a parameter from a model to a script. As you see I need to pass in a parameter LocNo.

Can you point me to an example that would help me figure out how to do that? I would still need to make it part of a script tool as this is part of a larger model.

Thanks Xander!

0 Kudos
XanderBakker
Esri Esteemed Contributor

I think that if you can create this variable in your model, you will also be able to create it within a script. I wouldn't include ModelBuilder at all, but I'm note sure what the content of LocNo is and what it is based on.

ChrisHolmes
Occasional Contributor III

LocNo is just a string value that would be provided by the end user.

Thanks

0 Kudos
XanderBakker
Esri Esteemed Contributor

Then there would be no problem to use a script instead of a a model. The script should also check for existence of the MXD file before you try to open it (especially if it is a string provided by a user).

ChrisHolmes
Occasional Contributor III

So would the code in the script be the same as what I put in the Calculate Value tool and does the passing the parameter part get handled in properties > parameters when I create the script tool?

0 Kudos
XanderBakker
Esri Esteemed Contributor

I have attached a sample toolbox. In the configuration of the script tool, you define a parameter. I called it "Loc No" and it is of type String. This value can be read from the script using arcpy.GetParameterAsText(0). The code in the python script is pretty much the same as you have.

ChrisHolmes
Occasional Contributor III

Great, thanks very much Xander.

0 Kudos