Contents
Can a function be defined in the code block parameter?
The Code Block parameter cannot be used on its own; it must be used in conjunction with the Expression parameter. Variables defined in the Code Block parameter can be referenced from the expression. Functions can be defined in the Code Block parameter and called from the expression.
How to use a variable created in ModelBuilder?
Variables created in ModelBuilder can be used by this tool, but variables desired for use in the expression parameter cannot be connected to the Calculate Value tool. To use them in the expression, enclose the variable name in percent signs ( % ).
When to use custom code and assembly references?
Use embedded code for custom constants, complex functions or functions that are used multiple times in a single report. Use custom code assemblies to maintain code in a single place and share it for use by multiple reports. Custom code can include new custom constants, variables, functions, or subroutines.
Can you access model variables from code block in Python?
In Python, part of syntax is proper indentation. Indentation level (two spaces or four spaces) does not matter as long as it is consistent throughout the code block. You cannot access model variables from the code block. Such variables must be passed to the code block from the expression.
Can a field calculator be used in attribute tables?
You can perform simple as well as advanced calculations on all or selected records. In addition, you can calculate area, length, perimeter, and other geometric properties on fields in attribute tables. The sections below include examples of using the field calculator. Calculations can be performed using either Python or VBScript.
How is the data type parameter used in calculate value?
The Data Type parameter is used in ModelBuilder to help chain the output of the Calculate Value tool with other tools. For example, if you use the Calculate Value tool to calculate a distance for use as input to the Buffer Distance parameter of the Buffer tool, specify Linear Unit for the Data Type parameter.