ModelBuilder Inline Variable Sub coming out as literal

609
1
08-06-2018 04:07 PM
GabrielMarcus
New Contributor II

My model will be run on successive days and I want a month and date to be appended to the end. I'm using a parameter  In my frustration to get this to work, I created a model variable,  (tried string, variant and 'any value' for the data type and made each a parameter. 

My problem is that inline variable substitution comes out as the literal input. For example "CombinedData_%StrDa%" 

StrDa is the name of the variable. Instead of substituting %StrDa% for its value, CombinedData_%StrDa%" is the name of the shapefile. I even tried %n% and it comes out as CombinedData_%n%

I've browsed and searched for the answer, but I haven't found anything. I'm running ArcGIS Pro 2.2.1

0 Kudos
1 Reply
curtvprice
MVP Esteemed Contributor

I get literal %'s when I mis-spell the variable name.  No idea why %n% wouldn't work; I just verified in 2.2.1 for me and variable substitution is working fine.

Sometimes you need to set the variable as a precondition to the tool that is creating the path you are specifying with that variable.

Data type should not matter, as long as the value itself is a string. You can create a datetime string for the current date with this expression in Calculate Value:

# Expression: 
datetime.datetime.now().strftime("%Y-%m-%d")
# Code Block:
import datetime
0 Kudos