Salad Tutorial 2 - Writing A Script: © Xtrados Pty LTD, 2007
Salad Tutorial 2 - Writing A Script: © Xtrados Pty LTD, 2007
Lets say we want to write a script to extract pipe support load information for transmission to the
Structural department.
Not all pipe supports need to be designed by a structural engineer however. Our example project
procedure states that structural design is needed wherever
So lets go ahead and define a couple of variables in the Input Variable section, Lv and Lh, to represent
these quantities. By defining these here we can quickly see and, if desired, change the figures used for
the exercise.
We begin the script by getting a list of pipe supports in the model, by using Salad’s restraintnodes
property. We use a new variable name ‘rn’ and assign the restraint nodes as below. You can assign
variable names ‘on the fly’, ie without pre-defining them or their type before assigning a value.
It is recommended to tick the ‘Working’ box when programming your script. This shows values assigned
in the output screen, which is helpful in error checking and finding problems (aka debugging). Click the
‘Execute’ button and you will see an output similar to the following. A comma-separated list of restraint
node numbers has now been assigned to variable ‘rn’.
Variable ‘lc’ now contains text consisting of the 16 lines shown. Looking at this output however brings
to mind the fact that we don’t want to consider certain load cases. Lets say we want to ignore ‘OCC’
and ‘EXP’ load cases. We can add a couple of lines to filter these out quickly:
The filter command doesn’t trigger a re-display of the filtered variable. However we can check it quickly
by adding a line to the script: ‘lc= lc’. The output is as follows, you will note that ‘OCC’ and ‘EXP’ cases
have been removed.
Now lets loop through all the restraints and the load cases to look for restraints which qualify as
structural supports. There are a number of ways to initiate a repeat loop, but perhaps the easiest is the
repeat for each form. Recalling that the restraint nodes are stored as a comma-separated list in variable
‘rn’, we can make use of the concept of items. Items are simply chunks of text or numbers in a list which
are separated by a common character known as the itemdelimiter, in this case a comma. The comma is
the default character for the itemdelimiter. Therefore we use the repeat for each item form for restraint
nodes, and the repeat for each line form for load cases:
This is a preliminary ‘skeleton’ showing how the repeat loops are constructed – at this stage no useful
output is created. The outer repeat loop goes sequentially through each restraint node in the list
variable ‘rn’ and assigns the node number to the variable ‘theNode’. The inner loop goes through each
line of the loadcase list ‘lc’ and assigns the line to the variable ‘theLine’.
Now lets add script to extract the data. It will be assumed that we are not interested in supports which
have moment restraint, these are normally internal to the piping system or imposed on equipment.
We will use variables ‘vmax’ and ‘hmax’ to track the maximum load for each support. These need to be
reset to zero for each restraint. We then get the load case number for each load case, recalling that this
is the second word in the load case description, eg “case 6 (OPE) W + T1 + P1 + WIN2”. Then we use the
MR[node,loadcase] data variable to check for bending moments and exit the loop if they are found.
Also it now occurs to us that we might be including in the list some restraints that are part of vessels or
other equipment. Let’s filter those out by limiting the maximum diameter of piping considered. We add
another Input Variable ‘Dm’ to set this quantity. We add a get statement in the main repeat loop to
check the diameter. If it exceeds ‘Dm’ we go on to the next restraint. The get statement can be used
when we don’t want to keep a value for long – it sets the value of a special reserved variable named it.
We also need to set structlist to empty before the first repeat loop, otherwise it would be considered
undefined rather than empty in the case of no structural supports. Finally, we add a message to show
progress, which can be desireable for larger models:
Further Improvements
The script currently gives a list of all restraints qualifying as structural supports for the model. The
script could be further refined and improved, for instance:
Note regarding the Language Reference (found under Help-> Language Reference):
The reference material has been extracted directly from Revolution’s help documentation. It refers to a
number of objects which are ‘building blocks’ of the Revolution programming environment, including
stacks, cards, groups, buttons, fields and files. These are not relevant to the use of Salad.