We will show you how to write your own scripts using a simple example. We assume that you have installed a scripting folder and its location is:
of course you can use own location. We will copy a 20-sim model to the scripting folder and write a script that will open this model in 20-sim and run a simulation.
|1.||Copy the example model FastManipulator.emx tot the Octave\tutorials folder. E.g copy:|
'C:\Program Files (x86)\20-sim 4.6\Models\Examples\Drivetrains\FastManipulator.emx'
|2.||Open a text editor (e.g. notepad) and enter the following lines:|
xxsimOpenModel( 'FastManipulator.emx' );
|3.||Save the text file as:|
|5.||Open Octave (or Matlab).|
|6.||In Octave/Matlab, change the local working directory. Type in the command line:|
|7.||In Octave/Matlab, run your own script. Type in the command line:|
Now you will see the model being loaded in 20-sim and a simulation being run.
In the tutorial folder there are more scripts. Use these as a template for writing you own scripts and follow the guidelines below:
Create your own subfolder inside your scripting working folder. This allows you to update the 20-sim scripting files when new versions of 20-sim are released.
You can find help on scripting functions in the 20-sim Editor by selecting Help - Octave Scripting API.