Add the script to Simulation Flow (Ctrl/Cmd + F2) > FramesPre.The goes through a Dyverso domain's ("DY_Domain01") particles and shifts every 20th particle - based on their Ids - and its neighbours to a second domain ("DY_Domain"). By altering the "skip" variable you can, for example, choose every 5th, 50th, or 100th particle:this script to a "Batch Script" editor (F10) and execute it with Script > Run.
The script creates a squared array of cubes and dyes the objects. Since the script works with integers only uneven numbers of cubes (3, 5, 7 ,9, etc.) can be used for "dimRange":
Code Block | ||
---|---|---|
| ||
numCubes = 5 # creates numCubes x numCubes object.
dimRange = (numCubes - 1) / 2 # calculate the dimension of the array
cubeCounter = 0 # initialize a counter
# Create nested loop for the horizontal axes
for i in range(-dimRange, dimRange + 1):
for j in range(-dimRange, dimRange + 1):
# Add a new cube and set its position
cube = scene.addCube()
cube.setParameter("Position", Vector.new(i, 0, j))
# Uncomment and use this line for Z-based setups:
# cube.setParameter("Position", Vector.new(i, j, 0))
# Here, the % (modulo) operator selects every 2nd cube
if (cubeCounter % 2 == 0): cube.setParameter("Color", Vector.new(255,255,255))
else : cube.setParameter("Color", Vector.new(255,32,32))
# Increment the counter
cubeCounter += 1
|