This is the most common type of function. These functions can have multiple parameters, but the last part of their body is always text to be interpreted. They create their own scope in which they define new variables, expression functions, and functions. Such variables and functions are available only within the scope of the function, which corresponds to its brackets.
The simplest example is $ExportProjectInfo. As shown in ProjectInformationFunctionSet, this function does not require parameters, only text. Its available variables are those it defines directly, and it does not define any functions or expression functions.
$ExportProjectInfo(Project $(projectName) has $(componentCount) components.)
This results in a sentence mentioning the project name and the number of components in the project.
The scope-defining function type has three subtypes, which differ in how many times the text in their body is interpreted, and the function $Using.
Function Using
Function sets are collections of variables, functions, and expressions. Some are available in every template, while others must be enabled with the $Using function. This lets you include only the sets you need, which keeps the template faster and easier to read.
For example, to work with control points and components, add:
$Using( "RealityScan.Report.ControlPointsExportFunctionSet" )
$Using( "RealityScan.Report.ComponentFunctionSet" )The $Using function is always available and should be placed at the beginning of a template.
If you don’t use and invoke only the function sets necessary for your needs, all function sets will be loaded at once. This may slow down processing when handling large amounts of data.
Functions Interpreting Text Once
These functions interpret the text part of their body once, and the result is just one iteration of the text.
An example of this function is $ExportProjectInfo, as showcased above.
Iterator Functions
These functions iterate through a list of items, such as models or inputs, and the text in the function is interpreted once for each item on the list. Each pass redefines its variables, functions, and expression functions according to the properties of the current item on the list, which is being processed. For example, the function $ExportModels iterates through all models in the currently selected component, and each iteration has data from a different model. This means that if we had two models, “Model 1” with 1,000 vertices and “Model 2” with 10,000 vertices, and we were to run the following template:
$ExportModels($(modelName) has $(modelVertexCount) vertices
)The result will be:
Model 1 has 1000 vertices
Model 2 has 10000 vertices