Application of commands: Groupfiltered and Apply


ApplicationPLAXIS 2D
PLAXIS 3D
VersionPLAXIS 2D 2015
PLAXIS 3D
Date created15 July 2014
Date modified15 July 2014

groupfiltered (grpf)

The groupfiltered command (with grpf being the alternative, short version of the command) operates like the normal filter command followed by a group command on the result. This is useful for parametrization, as it can be used to store intermediate results of queries. For example if you would want to get all points with 0 < x < 2, you can do this:

0003> point (0 0 0) (1 1 1) (2 2 2)
    Added Point_1
    Added Point_2
    Added Point_3
0004> groupfiltered Points "x<2"  # expect only the first two points 
    Added group Group_1 containing 2 items
0005> echo Groups[-1]
    Group named "Group_1"
    Contents (2): Point_1, Point_2
0006> groupfiltered Groups[-1] "x>0"  # only those items in the last created group that fulfill this condition 
    Added group Group_2 containing 1 items
0007> echo Groups[-1]  # should contain Point_2, which is the only with 0 < x < 2 
    Group named "Group_2"
    Contents (1): Point_2
0008> ungroup Groups[-2]  # throw away the intermediate group 
    Disbanded group Group_1
    

apply (map)

The apply command (with map being the alternative command) applies a command to multiple objects at once. This takes as parameters any list-like object, a command name and a set of parameters. It then loops over the contents of the list-like object and fires the specified command with the provided parameters on that object.

For example if you want to set the "x" value of all points to some value, you can do this:

0007> point (0 0 0) (1 1 1) (2 2 2)
    ...
0008> apply Points "setproperties" "x" 3
    OK
0009> tabulate Points "x"
    Object   x
    Point_1  3
    Point_2  3
    Point_3  3
    

In order for this to work, the object itself must implement the command in question (see the commands reference for this, or run cms MyObject to check which commands are available for any given object). For example the delete command is NOT implemented by a point, but by some higher-level object. You can therefore not use apply with delete in order to remove points.

Note: Undo stack: when you run apply it's as if you run multiple commands individually: there will be multiple undos.

The apply command will succeed if any of its subcommands succeeds. All outputs are however gathered in one big output: if one subcommand fails and some others do not, the entire result will be successful, but the feedback will contain information on the failure.

Example: Change material properties

In some cases, one wants to change one parameter for all (soil) materials. This can easily be done using the apply command:

apply Materials "sps" "psi" 2

This will apply the sps (setproperties) command to all Materials in the current model in order to change the value for ψ (psi) to 2°.

Combining the two: Groupfiltered and Apply

Let's say you have a large project with many phases and want to switch all of them except the initial one to use a max. of 2 CPUs (cores) and you want to store 10 steps for each phase. You can write this macro (see menu item Expert > Macro library) for it:

groupfiltered Phases "PreviousPhase!="  # all except the initial phase 
apply Groups[-1] "setproperties" "MaxCores" 2 "MaxStepsStored" 10
ungroup Groups[-1]  # get rid of temporary group to leave model clean 

This will work regardless of how many phases and/or groups you already have. It will only fail if you only have the initial phase, as that would try to create an empty group at the beginning.

Apply to groups from Structures mode

When defining a group in Structures mode, this group is accessible in the green modes (Mesh, Water/Flow conditions, Staged Construction). However, the apply command does not work directly on these groups from Soil/Structures mode in the green modes. Note: it does work correctly on groups made in the same (green) mode though.
Since PLAXIS 2D 2015, we can now use the apply command to easily set a parameter for the entire Structures mode- group using the command line, by calling the apply command on the apply command.

Settings mesh coarseness for a group

Say we made a group of polygons and lines in Structures mode, called Group_1, and in Mesh mode we want to change the local mesh coarseness for all group members to 0.75, we need to call the apply command on the group members, like this:

apply Group_1 "apply" "sps" "CoarsenessFactor" 0.75

Changing materials for a group

When you make a group of volumes in Structures mode called Group_X, and you want to apply the same material, e.g. Concrete1, in a phase, say Phase_X, this is how the command should look:

map Group_X "map" "setmaterial" Phase_X Concrete1

 

See also