Is there any way to add arbitrary code snippets to an ArcGIS model?
I envision something similar to the "show code block" the expression builder in advanced labelling or field calculator.
For example my project of the moment could benefit greatly from fetching the username of the person running the tool. I know in python this is a simple import os; os.environ.get('USERNAME')
. I think I could write that snippet to get_username.py
, add it to a toolbox in Arccatalog, then add that tool to the model and use it as per-requisite model parameter for my current tool. That's a lot of work for such a small thing, and next time I might want something else, like inline variable substitution or a compound variable.
I think a code snippet tool or similar could be address all of these needs in a generic, broadly helpful manner.