I am trying to connect three models I build in ModelBuilder within an ArcPy script.
The first model gets its parameters defined by the user. Whereas the other two models will get some parameters from the output of the first model. I use inline variable substitutions in all of the models which leads to the main problem.
The output of the first model (.shp) is saved as a python variable that I try to pass as a parameter to the second model. When I print this variable, I get the filename with the inline variable substitutions (%Name%_filename.shp).
print(kom_ug) # C:/Users/bjbr/Desktop/test_bjoern/test/shape\%Name%_ug.shp
This causes the error. The second model isn´t able to find the variable in the directory since the shapefile is stored as
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\bjbr\Documents\ArcGIS\Toolbox.tbx", line 26, in KomBufferTool ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Kommune_Endringer_ug: Dataset C:/Users/bjbr/Desktop/test_bjoern/test/shape\%Name%_ug.shp does not exist or is not supported The value does not exist.
When I hardcode the variable name the error disappears, but I would like to work with these inline variable substitutions to comfortably handle a higher volume of data.
Does someone have an idea how to work with inline variable substitutions when calling a model in ArcPy?