I am needing help determining syntax of inline variable to use string from field name instead of 1..2...3..
Your question is unclear to me. Have you tried looking at %Value%, which has the value for each iteration?
Thanks for the response. To clarify, I am trying to iterate through feature class using OID, but would like to return Name field in output. sp. Clip%Name%
is this possible?
In ModelBuilder 10.x you can access this value from the feature layer output for the iterator using the Get Field Value tool. The output of that tool will be the value (say, %Name%) you can use in the output file name.
Another approach I've used is include the OID and name field in the iterator - then you can parse the value out of the iterator label element using the Calculate Value tool. For example on an iteration the iterator label element may be "1_Foo", you can then use Calculate Value to get the value using this expression:
the above expression returns "Foo" if Value is "1_Foo".
Can you point me to some documentation, or examples of the expression syntax similar to that above. I'm wanting to do something similar but strip off the last 4 characters of %Value%. So if %Value% = raster.tif, I want to use %Value% plus an expression to get raster.shp
>>> import os >>> os.path.splitext("e:\\work\\image.tif") 'e:\\work\\image'
def f(path): import os return os.path.splitext(path)
def f(Value): import os return Value[-4]
In the interest of making it a bit more universal for future use, would the following remove the last 4 characters from a string stored in %Value% ?
>>> "file.tif" '.' >>> "file.tif"[:-4] 'file' >>> "file.tif"[-4:] '.tif' >>>
Should the line of code be encapsulated with f() ?