Creating a triangle in the XZ plane


I am a new user of this software and I am trying to make a 3D triangular structure with the triangle in the XZ plane. I used the standard addtriangle function to create an equilateral triangle in the XY plane and then I used 90 degree rotation with x-axis first axis. But the dimensions of the triangle are not retained (isn’t equilateral anymore).

Is there a way to write the script such that the triangle is created in the XZ plane?

Here is the script i have for add triangle and 90 degree rotation:
#triangular structure

*vtx = [0,0;2,3.46;-2,3.46]1e-6; # microns




set(“z span”,30e-6);



set(“first axis”,“x”);

set(“rotation 1”,90);

Thank you in advance.

Hi @smajety,

Welcome to the community!

Running the script you provided does make the intended rotation (with the triangle base on the XZ plane while retaining dimensions); note that the XZ view doesn’t demonstrate a 1:1 ratio. You can verify the dimensions of your structure using the ruler (shown below).


You also have the option to apply the rotation through property editor of the structure (check this article).

Kind regards

Hi @kghaffari. Thank you for the clarification. I have working on making structures after your response and I have two questions:

  1. How can I reset the aspect ratio of the XZ and YZ view panes? The aspect ratio I have in my panes after several zooms in and out is bad enough that it just looks like a line (dimension in z >> dimension in x). I am unable to see the structure in those panes.
  2. I was writing a script of periodic holes in the triangular structure I mentioned above but the individual structures move to a different (x,y,z) every time i run the script. I think it is because of the coordinates not being relative to each other. Is there a command to fix the coordinate system and define each of the individual structures relative to each other?

Thank you.


Regarding your question number 1, take a look at the following post for a workaround. I don’t know if there is a proper way to fix the aspect ration yet, but this will help.

1 Like

Hi @smajety,

You can reset 2D view aspect ratios by selecting your structure and using the zoom extent option:


Regarding your second question, would you please share your simulation file and the script you used, so I can recreate the issue?

Kind regards

Hello @kghaffari

Thank you @kghaffari and @ie5003_allison for answering question 1.

@kghaffari regarding question 2, I am attaching the sample code I was talking about in my previous messages. If you run the script multiple times the circles and the triangular structure move apart. The circles need to be located symmetrically based on how i defined the coordinates.

Ask we speak about the script, is there a command to extract the x, y, z values at the end of the for loop and use it as the new x, y, z values for the next for loop and so on?paper structure.lsf (1.6 KB)

Thank you for your time.


In case you’re in need of a quick response…
I believe that the reason “the circles and the triangular structure move apart” is simply because you do not define the x,y,z position of your triangle in your script, so the triangle is placed kind of randomly (probably where the cursor is). The x,y,z position of the circles is defined in the script so they are always added at the same position. So, it would be better to include in the script some code to define the x,y,z position of the triangle before you start adding the circles.
As I understand your script and your last question, once your loop has finished, x0, y0+a1*i, and z0 are the values at the end of the for loop, so you can simply start the next for loop with those values. Alternatively you can use the get command, e.g. get("y"), if you prefer to get the information directly from the last circle.

Hi Sridhar,

As @ie5003_allison mentioned, this is because your script doesn’t set the initial position for the triangle (x, y, z position); Therefore, this will be done automatically by the solver and the object will be placed in the middle of 2D view planes, resulting in your overall geometry changing each time you navigate the 2D views.

This can be fixed by simply setting the x, y, z position in your script.


is there a command to extract the x, y, z values at the end of the for loop and use it as the new x, y, z values for the next for loop and so on?

If I understood your question correctly, as @ie5003_allison mentioned, the values you intend to extract from an initial for loop are already stored in the variables you are using (e.g. x0, y0 + ai*N, z0 from the first for loop). Alternatively, you can use the get command to store the coordinates in a new variable.

Further useful information regarding scripting can be found on our scripting course and Knowledge Base.

Kind regards

Actually, the expression “select(“triangle”)” can be neglected here since only one object is used and it is the current object.
If one changes current object to another one and goes back to the previous one, one needs to select previous object. Otherwise, it cannot be recognised.


@kghaffari @ie5003_allison @quentinl Thank you all for answering my questions patiently. I fixed the script and I am able to generate the structure I need, based on your comments.


1 Like