1

I'm building a bike network dataset based on an existing street network. Each bike lane/route/path has a unique ID number (assigned by our engineering deparment) that must be included in a separate ID field within each feature class. We recently changed the base for our street network, necessitating a redraw of about 4000 segments.

To save time manually adding fields, I built a model to add the new ID field "BPID" (which must be saved as a short integer), a "BPID_Temp" field, used to convert the string values to numbers by trimming the leading character (expression is =Right( [BPID_TEMP], Len( [BPID_TEMP] )-1 ) and then copying it to the permanent BPID field. Lastly, I delete the temporary ID field.

Here is an image of the model below: Model w/ 1st Calculate Field Expression

At the first Calculate Field step, the value from Parse Path is not being transferred into the BPID_TEMP field. The expression for the step is "Value", in PYTHON. Parse Path is set to NAME, and the model runs through without throwing any errors.

I've gone through Using Feature Class "Name" from Iterate Feature Classes to Calculate Field with ModelBuilder?. However, adding wildcards to the "Value" expression returns an invalid expression error. If I link the "Value" output from Parse Path directly into the Calculate Field (rather than as a precondition), it tells me that I am trying to calculate a number that is too large, or mixing incompatible data types.

Am i missing something critical here. I can run the steps manually no problem, but as soon as I try to automate with an iterator, it all falls apart. I'm not great with Python yet, but I feel like it isn't even necessary here.

2
  • 1
    You need to add to your question a screen shot of that first field calculate which is causing the problem. Without seeing how you set the tool up, it is difficult to answer this question.
    – Hornbydd
    Commented Sep 12, 2015 at 15:25
  • @Hornbydd, image edited; sorry about that!
    – JonR
    Commented Sep 13, 2015 at 1:32

2 Answers 2

1

So, not sure if there was still a syntax problem, but I switched to a different machine, and with a few tweaks, it worked correctly.

I had to rebuild the model, since I didn't have access to my original files on this new machine. Built it up exactly the same, and if went through flawlessly.

Besides the hardware configuration, the only thing that changed was the version of ArcMap; first attempt was with 10.2, and the functioning version was with 10.3. Final model with expressions is below:

enter image description here

1
  • Odd, other than the parse path tool the rest of the logic is the same. Don't worry you are not the first person who tries something with modelbuilder, give up, try exactly the same thing then it works! Like you I often put labels on the model as it helps others read the logic.
    – Hornbydd
    Commented Sep 15, 2015 at 7:25
0

The technique you are using is called in-line substitution, this is how you pass a value in a variable around a model. More examples and information can be found in the desktop help.

You have the Syntax wrong. When you reference a variable it must be within %%, so in your case it would be %Value%. As some tools take strings as inputs you might need to enclose your in-line variable within quotes such as "%Value%". I don't know if you need to do that as the output of parse path is a string, just try it.

7
  • I should mention that all of this work is occurring in a geodatabase. I know that can change the delimiter and wildcard types sometimes.
    – JonR
    Commented Sep 13, 2015 at 21:04
  • Running the model with the syntax "%Value%" returns null fields in BPID, but without any errors. Using the syntax %Value% stops the model at the first Calculate Field tool, with the error message below: ERROR 000539: Error running expression: L275 Traceback (most recent call last): File "<expression>", line 1, in <module> NameError: name 'L275' is not defined Failed to execute (Calculate Field).
    – JonR
    Commented Sep 13, 2015 at 21:14
  • Trying varying syntax combinations seem to result in a null value being passed from the iterator, rather than the actual feature name. Parse Path is set to NAME, so I don't understand why it would pass a null value to the variable.
    – JonR
    Commented Sep 13, 2015 at 21:34
  • Are you trying to put a text value into a numeric field?
    – Hornbydd
    Commented Sep 13, 2015 at 21:40
  • No. That is the reason for the BPID_TEMP field. Once I can get the variable to transfer into that field, the Calculate Field (3) tool will strip out the leading character, leaving only numbers that can be copied into the BPID field with Calculate Field (2), which is a short integer field. I can do this all by hand in the attribute table without any problems.
    – JonR
    Commented Sep 13, 2015 at 21:53

Your Answer

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

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