,

Creating looping operations to repeat over a set of entities

We have seen in our previous post how to modify a recorded process so that it can be applied to any cylinder. You can refer back to it here. If we look at the process editor, this is where we last were:

CapCylinder2

In this post, we will continue our modification of the process to have it be applied to a set of cylinders in our current model, using looping operations. The first step is to remove the process variable CYLINDER we created earlier. For this, we open the variable window, select the CYLINDER line and press Delete Variable.

Variables

Our process will continue to use the CYLINDER variable, but instead of having its value defined when starting the process and be maintained throughout, we want the value of CYLINDER to change in order to cover each cylinder in the model. For this, we will need to create an operation.

Operations are a great way to organize our process to make understanding it more straightforward. In addition to this organizational role, operations are used in BuildIT process automation to define a set of repeating (or conditional, as we will see later) commands.

To create the operation, we select all the commands in our process, then press the New Operation button, which will create the operation and group everything that was selected under it.

Then, we put out CYLINDER variable name as the Loop Variable for the operation and use the FIND function to dynamically create a list of objects (under Loop List) from the contents of the model.

CapCylinder3

In order to allow the operator to follow along when the process will be executing, we’ll add a message output at the top of the operation to inform him of which cylinder we are currently processing.

NewCommand

As you can see below, in addition to the cylinder name (the CYLINDER variable) we also included the current position in the loop, using the LOOPINDEX and LOOPTOTAL system variables.

CapCylinder4

System variables are pre-defined variables that are available to your process, in addition to any variable your define yourself. As a convention, we use the underscore character as a prefix and suffix to system variable names in order to make it clearer that these are not defined by the user.

The system variables available are:

  • $(_ACTIVECS_): The name of the active coordinate system (« World Axes »)
  • $(_ACTIVEDEVICE_): The name of the active device (« Device1 », blank if none)
  • $(_ACTIVEPLOT_): The name of the active plot (blank if none)
  • $(_ACTIVEPROBE_): The probe offset of the active device, in the current units (« 0.75 »)
  • $(_DATE_): Date at the start of the execution of the process (« 2012-02-07 »)
  • $(_ERRORS_): The number of commands that returned a process error since the start of the process or the last General_ClearErrors command.
  • $(_ERRORID_): The command ID of the last command that returned a process error.
  • $(_ERRORNAME_): The command NAME of the last command that returned a process error.
  • $(_LOOPINDEX_): The current iteration within a looping operation.
  • $(_LOOPTOTAL_): The total number of iterations of a looping operation.
  • $(_MODEL_): The file name of the current model without extension (« Model »)
  • $(_MODELPATH_): The full path of the current model (« C:Documents »)
  • $(_TIME_): Time at the start of the execution of the process (« 15-40-02 »)
  • $(_TIMESTAMP_): Timestamp at the start of the execution of the process (« 20150630-154002 »)
  • $(_USER_): Username of the active Windows user (« mathieud »)
  • $(_UNITS_): The abbreviated name of the current units (« mm. », « in. », « m. »)

When running, this process will show the message in the 3D view, over the model.

DisplayMessage

In a future post, we’ll see how we can use other options of the FIND functions to restrict the operation to a subset of all the cylinders from our model.

0 réponses

Répondre

Se joindre à la discussion ?
Vous êtes libre de contribuer !

Leave a Reply