Model Builder Calculate Value Tool ERROR 000354: The name contains invalid characters

4305
8
07-05-2017 11:42 AM
TimBarker
New Contributor II

ArcMap Desktop 10.1

I'm trying to build a simple Calculate Value Tool entry in a model to concatenate some variables together into an output shapefile name.  Cannot get it to work even though the expression evaluates correctly.  I have simplified and simplified it trying to find source of error.  I now have the simplest of entries.  I put a simple text string into the expression and it still will not get past the tool.

Executing (Calculate Value): CalculateValue "calcname1" # String
Start Time: Wed Jul 05 12:35:54 2017
Value = calcname1
ERROR 000354: The name contains invalid characters
Failed to execute (Calculate Value).
Failed at Wed Jul 05 12:35:54 2017 (Elapsed Time: 0.00 seconds)

I have tried arcpy.ValidateTableName() - no difference.

What 'name' has invalid characters?  

I chopped everything out of the model to where there is just the Calculate Value tool trying to evaluate the one input text string.  It will not successfully finish.

Help?

0 Kudos
8 Replies
JayantaPoddar
MVP Esteemed Contributor

Could you attach the screenshot of the model/expression?

Ensure that the result of the expression (name) doesn't have any special characters (except underscore) and it doesn't start with a numeric value.



Think Location
0 Kudos
DanPatterson_Retired
MVP Emeritus

was  the ... # string... portion in the original?  I know it is ok as a comment for python, but not otherwise

0 Kudos
IanMurray
Frequent Contributor

I think the # was the placeholder for a blank expression for the second parameter of Calculate Value.  Arc uses them all the time for optional parameters left blank in geoprocessing operations.

0 Kudos
DanPatterson_Retired
MVP Emeritus

ahh, I didn't know it gave the data type as well, I knew about the # bit

0 Kudos
curtvprice
MVP Esteemed Contributor

Dan, this is a very helpful parameter!  The Data Type parameter of Calculate Value allows you to use code to construct a string representation of an object (say for extent), if you set the data type it allows model builder to recognize that data type to allow you to connect the Calculate Value output to a tool that requires that particular data type (like Extent, Cell Size, Coordinate System, etc). 

curtvprice
MVP Esteemed Contributor

This is strange, this works for me:

Calculate Value screenshot

Executing (Calculate Value): CalculateValue "calcvalue1" # String
Start Time: Wed Jul 05 15:16:57 2017
Value = calcvalue1
Succeeded at Wed Jul 05 15:16:57 2017 (Elapsed Time: 0.06 seconds)‍‍‍‍

to get back to your need:

I'm trying to build a simple Calculate Value Tool entry in a model to concatenate some variables together into an output shapefile name. 

You don't need to use Calculate Value, you can just enter them your output path:

C:\output_folder\%element1%%element2%%element3%
MalcolmMeyer2
Occasional Contributor II

Similar problem - 

Start Time: Mon Sep 30 10:56:14 2019
Succeeded at Mon Sep 30 10:56:14 2019 (Elapsed Time: 0.35 seconds)
Executing (Calculate Value): CalculateValue validate(r"coz.DBO.utl_stormwater_impervious") "def validate(string):\n return (string).replace(".", "_")" "Any value"
Start Time: Mon Sep 30 10:56:14 2019
Value = coz_DBO_utl_stormwater_impervious
ERROR 000354: The name contains invalid characters
Failed to execute (Calculate Value).
Failed at Mon Sep 30 10:56:14 2019 (Elapsed Time: 0.00 seconds)

The tool runs, gives me the needed value, but then errors out...why? I have seen this referenced here as well - Model builder: iterative Excel-file import and Shapefile output. I also tried with ValidateTableName with the same error. I just need a valid table name from an SDE database, without the dots.

0 Kudos
MalcolmMeyer2
Occasional Contributor II

A computer restart fixed this and is now working as expected...that is weird.