Rotating an element using script commands


#1

Hi everyone,

I would like to implement rotation of an element by some angle using script commands. I tried using rotatelement function but it did not work and flagged an error that the function could not be found. Do I need to set some object property and then use the same in script? Please help. I am quite new to the software and don’t know much about it. Many thanks. :slight_smile:


#2

Hi, @eez168085,

Here is the relevant information on rotation by means of script commands:
https://kb.lumerical.com/en/ref_scripts_tutorial_set_object.html

As an example, please find my script in attachrotation.lsf (174 Bytes)
ment.


#3

Hi @eez168085
For example, let’s select the directional coupler from the object library and you want to rotate it using script commands.
1)First of all insert the directional coupler and then Click right—>Edit Object
2)“Edit structure group” will open —>Select the “Properties” tab and add “New property” with name “start angle” and “type”=number
3)Go to “Script” tab and insert the variable name in the beginning “start_angle = %start angle%;” and a few lines above after the “selectall;” you can type "set(“rotation 1”,start_angle);"
4)Click Test and OK

Edit again the directional coupler and give the start angle value that you want in the property’s tad


#4

I have finally figured out what was wrong in my code. Thanks a lot for your help. :slight_smile: