Script
Documentation of Javascript API
The documentation of script functions and tutorials are accessible through the Javascript API Documentation.
Usages
The Script Plugin can be used to execute Javascript code either from the command line or the software's main Graphical User Interface.
From the application's main window
From the command Run Script.
From the command line
When using the Script Plugin from the command line, you can specify several command line arguments as listed below:
Argument |
Description |
Example |
--Script |
Open script dialog box at startup and load a script from the given file path. |
--Script="D:/script.js" |
--ScriptOutput |
Writes the console output into a given file. |
--ScriptOutput="D:/output.log" |
--Silent |
Silent Mode. Disables the Graphical User Interface (no windows). |
--Silent |
--ScriptParam |
You can specify additional scripting code, which will be executed just before the specified input script (if any). It's useful to give argument to the script from the command line. As example, you can give the .3dr filename inside a variable named fileToLoad, and then, use it inside the .js file to open that file. Sample js file which used a variable define with --scriptParam
if ( typeof fileToLoad === "undefined" ) throw new Error( "variable 'fileToLoad' must be define using --scriptParam" ); var res = OpenDoc(fileToLoad); ... |
--ScriptParam="var fileToLoad='d:/Project/3drfile.3dr';" |
--ScriptAutorun |
Automatically runs the script once the application has been initialized. If –silent is not defined, run automatically script after opening the dialog box. |
--ScriptAutorun |
Example
Here is an example for executing from the command line:
3DR.exe --script=
"D:/Tuto/SmoothPoly.js"
--scriptOutput=
"D:/Output.log"
--silent --scriptParam=
"var deviation=0.12; print('Use deviation control: ' + deviation);"
This command line:
Starts the application in silent mode, no window, only an icon inside the taskbar.
Executes the script SmoothPoly.js
Writes the console output into the file "D:/output.log"
Prints "Use deviation control: 0.12"