1

I am experiencing an issue with the model only tool Calculate Value. I am attempting to use the Parse Path and Calculate Value model only tools to force a feature dataset into the Create Topology tool.

  1. The first parse path tool is taking the path
  2. The second parse path tool is taking the file (Feature dataset)
  3. The calculate value tool is combining the two strings and changing the data type to feature dataset using this expression ("%Path%"+"\%File%") (which will connect to the create topology tool)
  4. The problem is when combining the two strings, the calculate value tool is truncating a portion of the path name, specifically the number in the path name.

When running this model on a path with no numbers in it, it runs fine.

I also tried using the the calculate value tool again to replace the truncated characters with the correct ones, and still it breaks the model.

There is some issue with calculate value not accepting numbers in path names.

Can anyone help with this issue?

enter image description here

enter image description here

enter image description here

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jun 16, 2015 at 13:57

1 Answer 1

3

In Python, a backslash in a string always signals the presence of a special character. For example, a "\t" will be interpreted as a Tab.

I tested your "Calculate Values" expression in ModelBuilder with a path of "C:\Workspace\trash\temp.gdb\poly", and my result was "C:\Workspace rash emp.gdb\poly". Each "\t" was changed to a Tab.

To prevent python from interpreting characters after the backslash as a special character, add an "r" before the string. The version of the expression below calculated the correct string.

r"%Path%\%File%"
answered Jun 16, 2015 at 15:43
1
  • Thanks you. That does fix the issue in question, however it causes another issue down stream in my particular model. On the model that I mentioned I tested that does not contain numbers in the file path, changing the string to a raw string does not affect the model. (Still works fine) On the model that does contain the numbers in the file path, changing to a raw string causes the model to break further down the line than it was. Not sure why. Thank You for your help. Commented Jun 16, 2015 at 16:46

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.