Script Editing - Tutorial 1- Draw a line
Let's start with a very basic example.
Copy and paste the code below into the text editor , and save the script file "Example1" . No need to specify any file extension.
With this script a segment will be created from coordinate 0,0 to coordinate 50,50
public void Tutorial_1a()
{
AddLine(0, 0, 50, 50);
}
Come back to ecam window, without closing script editor, and start typing "tutorial_1a" into command line .
After typing few charaters , the command line will suggest you a possible function candidate.
If more function are found , use the arrow up and arrow down keyboard keys, to select your desidered function .
Press keyboard [ENTER] to accept the suggested function or continue type the command name.
Press [ENTER] again to run the script
A line will be created and now you can see it in the viewport.
Function with parameters
Now we are going to add some parameters to the function .
The function body is similar to previous example , but now the function require two parameter to run correctly.
These 2 parameter define the line endpoint.
public void Tutorial_1b(double x, double y)
{
AddLine(0, 0, x, y);
}
We can define the value of these parameters in 2 ways :
1) With Command Line
Into the command line in ecam window we can call this function like this :
tutorial_1b x -50 y 50
Is important set the space between parameter name and parameter value.
The string has this sctructure
function_name param1_name param1_value param2_name param2_value
2) Define parameter through parameters dialog window.
Into the command line in ecam window , we can call just the function name like this :
tutorial_1b
If one or more required parameter are missing, a dialog window will be shown like in the image :
Insert the various missing parameters and press keyboard [Enter] to move the focus to the next row. and at the last row , it run the script.