Model builder has the Calculate Value tool that allows you to run small python scripts within the model. This is a powerful tool that allows you to run complex python logic or even bring arcpy functionality into the rigid framework of model builder. I use it all the time.
The tool interface is not a fully featured IDE environment, its a small clunky space to write code and consequently a great place to make typo errors that cause the code to fail. When it fails you get a Traceback error, an example is shown below:
Start Time: 23 November 2021 17:40:53
ERROR 000539: Traceback (most recent call last):
File "<expression>", line 1, in <module>
File "<string>", line 4, in SetSymbology
IndexError: list index out of range
Failed to execute (Calculate Value).
If the script is long then you have to work out where the line it has failed on is in your code, in my example above thankfully it fails on line 4.
So one has to go back into edit mode on model builder, open the tool then scroll down and review the code and work out what went wrong.
What would significant improve the user experience is if the code block parameter of the tool interface also showed the line number. Now this could be an option that maybe the user can turn on or off, I would certainly have it on!
I would envisage something like below with the blue writing as way of example:
The number needs to scroll as you scroll down the code as the code block "space" is fixed and you cannot stretch it to fill the tool window.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.