shift all elements in the group

I am new in lumerical package and have the following question:
I have created the 3D array of close packed spheres and add them to the group.
It is necessary to shift each element in z directions by the same value.

I add shift = 40 nm parameter to the group parameters and run the following code in the group script window

z = get(“z”);
new_z = z + shift;
set(“z”, new_z);

After this, only one of ten layers of spheres stay in the visible scope.
May be I have to loop throught list of all selected sphere objects and consequentially shift them?

Could you help me.
Thank you in advance.

Hi @pralex, It is hard to tell exactly why some of the elements are going out of view. However, one mistake that I would like to point out is that adding a shift to the existing elements of the group in this manner is not ideal. The problem that you will face is that every time the solver executes the script in the group, it will keep adding a 40 nm shift to the objects. So every time you open the structure group and close it you will see the objects move by 40 nm.

That said, the easiest way to add a shift to all the objects in your group is to shift the group itself. You can do this from the properties of the structure groups as shown below:

Alternately, if you want to add the shift in your script then you will have to write it in such a way so that the z position of the elements are calculated as an absolute value that will not change every time the script gets evaluated.

If you still have the issue you’ve mentioned “only one of ten layers of spheres stay in the visible scope” after correcting this error then please let me know.