\hypertarget{scripting_scripting_batch_mode}{}\section{Open\+Flipper Batch mode}\label{scripting_scripting_batch_mode}
Open\+Flipper can be started in batch mode without a graphical user interface by providing \char`\"{}-\/b\char`\"{} as a command line option. Furthermore you have to provide an Open\+Flipper script (extension is .ofs), which will get executed. To get output to the command line, you also have to provide the command line switch \char`\"{}-\/c\char`\"{}. Only plugins which support batch mode ( They implement an nogui() function ), will be loaded. For example, no renderers, postprocessors or other plugins providing only user interface or graphical functionality will be loaded. You can see on the command line (when \char`\"{}-\/c\char`\"{} is given), which plugins are activated and which are skipped in batch mode.\hypertarget{scripting_scripting_iterating}{}\section{Iterating over objects}\label{scripting_scripting_iterating}
In the scripting system you can also iterate over objects in the scene.


\begin{DoxyCode}
\textcolor{comment}{// Get a list of all target triangle meshes in the scene}
var list = datacontrol.getTargetObjects(\hyperlink{classDataType}{DataType}(\textcolor{stringliteral}{"TriangleMesh"}));

\textcolor{comment}{// Print the names of all target objects}
\textcolor{keywordflow}{for}( \textcolor{keywordtype}{object} in list )
\{
  print(datacontrol.getObjectName(list[\textcolor{keywordtype}{object}]))
\}
\end{DoxyCode}
\hypertarget{scripting_scripting_datattypes}{}\section{Data\+Types}\label{scripting_scripting_datattypes}
In the scripting system the type \hyperlink{classDataType}{Data\+Type} is already known. You can do for example 
\begin{DoxyCode}
\hyperlink{classDataType}{DataType}(\textcolor{stringliteral}{"TriangleMesh"});
\end{DoxyCode}
 You can get a string list with all available data types via 
\begin{DoxyCode}
\textcolor{comment}{// Get the string list of data types via DataControl Plugin}
var types = datacontrol.availableDataTypeNames();
\end{DoxyCode}
\hypertarget{scripting_scripting_datattypes_getting_type}{}\subsection{Getting the Data\+Type of an Object}\label{scripting_scripting_datattypes_getting_type}

\begin{DoxyCode}
\textcolor{comment}{// Set the object id}
var \textcolor{keywordtype}{object} = 5;

\textcolor{comment}{// Get the DataTypes and print its name. the DataType is returned by the function}
print(datacontrol.dataType(\textcolor{keywordtype}{object}))
\end{DoxyCode}
\hypertarget{scripting_scripting_datattypes_getting_id}{}\subsection{Getting the Id of an Object}\label{scripting_scripting_datattypes_getting_id}
Openflipper provides functions gathering the id of an object. Also, some functions create an object and return its id. Some examples\+: 
\begin{DoxyCode}
\textcolor{comment}{//Various ways of gathering id and or name of an object}
var objectId   = core.loadObject(QString)               \textcolor{comment}{//generate an object and returns its Id}
var objectId2  = core.getObjectId(QString)              \textcolor{comment}{// returns Id by object name}
var objectName = datacontrol.getObjectName(\textcolor{keywordtype}{int})         \textcolor{comment}{// returns object name by Id}
var objectList = datacontrol.getTargetObjects(\hyperlink{classDataType}{DataType}) \textcolor{comment}{// returns IdList of all target objects}
var objectId3  = primitivesgenerator.addPyramid()       \textcolor{comment}{//generate an object and returns its Id}
...
\end{DoxyCode}
\hypertarget{scripting_scripting_vectortype}{}\section{Vector data type}\label{scripting_scripting_vectortype}
The Vec3d used in the C++ code is mapped to the scripting language. Details can be found here\+: \hyperlink{scripting_vector_type}{Vector data type for scripting}\hypertarget{scripting_scripting_vector4dtype}{}\section{Vector4 data type}\label{scripting_scripting_vector4dtype}
The Vector4d data type is corresponding to the Vec4d type in C++. It is mostly used for colors. Details can be found here\+: \hyperlink{scripting_vector_type_4d}{Vector4d data type for scripting}\hypertarget{scripting_scripting_matrixtype}{}\section{Matrix data type}\label{scripting_scripting_matrixtype}
The Matrix4x4T type used in the C++ code is mapped to the scripting language. Details can be found here\+: \hyperlink{scripting_matrix_type}{Matrix data type used for scripting}\hypertarget{scripting_idlisttype}{}\section{Id\+List type}\label{scripting_idlisttype}
Some functions can perform the same operation on several objects or give multiple objects back. The Id\textquotesingle{}s of these objects are saved in a Id\+List. This is a simple list of integer containing the id\textquotesingle{}s. Example code\+: 
\begin{DoxyCode}
\textcolor{comment}{//Assume, "Object 1" and "Object 2" are already created or loaded}
var id1 = core.getObjectId(\textcolor{stringliteral}{"Object 1"})
var id2 = core.getObjectId(\textcolor{stringliteral}{"Object 2"})
var list = [id1,id2]
datacontrol.groupObjects(list)
\end{DoxyCode}
\hypertarget{scripting_qVariantMaptype}{}\section{Q\+Variant\+Map type}\label{scripting_qVariantMaptype}
The Q\+Variant\+Map type is used by some function as input. A Q\+Variant\+Map is similar to a map with key and value, where the types of the key and value is not defined. Mostly, the keys are {\itshape strings} describing the property where the value type is of type {\itshape int}. Example code\+: 
\begin{DoxyCode}
\textcolor{comment}{// creating a scripting object}
var constraints = \textcolor{keyword}{new} Object()
\textcolor{comment}{// filling the QVariantMap}
constraints["decimater\_type"] = 0 
constraints["decimation\_order"] = 0
constraints["vertices"] = 50
\textcolor{comment}{// load e.g. mesh object}
var \textcolor{keywordtype}{id} = core.loadObject("MyTriangleMesh.obj")
\textcolor{comment}{// perform decimation}
decimater.decimate(\textcolor{keywordtype}{id},constraints)
\end{DoxyCode}
\hypertarget{scripting_scripting_misc}{}\section{Miscellaneous}\label{scripting_scripting_misc}
\hypertarget{scripting_scripting_misc_path}{}\subsection{How to get the path of the current script?}\label{scripting_scripting_misc_path}

\begin{DoxyCode}
\textcolor{comment}{// The path of the currently executed script is stored in the ScriptPath variable.}
print(ScriptPath)
\end{DoxyCode}
 \hypertarget{scripting_scripting_misc_includes}{}\subsection{Can i include additional script files?}\label{scripting_scripting_misc_includes}
Yes, just use the keyword include. You can also use paths relative to the current script. The scripts will be joined internally so variables are available across the scripts. 
\begin{DoxyCode}
\textcolor{comment}{// Include with full path:}
include <Path/script1.ofs>

\textcolor{comment}{// Relative to current script:}
include <ScriptPath/script2.ofs>
\end{DoxyCode}
\hypertarget{scripting_scripting_examples}{}\section{Scripting Examples}\label{scripting_scripting_examples}
\hypertarget{scripting_scripting_examples_qstringlist}{}\subsection{Iterating over a Q\+String\+List}\label{scripting_scripting_examples_qstringlist}

\begin{DoxyCode}
\textcolor{comment}{// Get the string list of data types via DataControl Plugin}
var types = datacontrol.availableDataTypeNames();

\textcolor{comment}{// Iterate over the list and print to the console}
\textcolor{keywordflow}{for} ( i = 0 ; i < types.length ; ++i ) \{
  print(types[i]);
\}
\end{DoxyCode}
 \hypertarget{scripting_vector_type}{}\section{Vector data type for scripting}\label{scripting_vector_type}
The vector data type is corresponding to the Vec3d type in C++. The implementation of the scripting type is done in \hyperlink{classprototypeVec3d}{prototype\+Vec3d}.

You can use the following functions\+: 
\begin{DoxyCode}
var vec = \hyperlink{DataTypes_8hh_a7932a926ab17fabe9f4a0ee1b498526c}{Vector}(1,2,3)
var vec2 = \hyperlink{classOpenMesh_1_1VectorT}{Vector}(10,20,30)

vec.multiply(0.5)           \textcolor{comment}{// Multiply vec with 0.5}
vec.add(vec2)               \textcolor{comment}{// Add vec2 to vec}
vec.sub(vec2)               \textcolor{comment}{// Subtract vec2 from vec}

var \hyperlink{classOpenMesh_1_1VectorT_afac3b9b6e93f8f47603f39ee387cb9a9}{norm}    = vec.\hyperlink{classOpenMesh_1_1VectorT_afac3b9b6e93f8f47603f39ee387cb9a9}{norm}()    \textcolor{comment}{// Calculate the length of the vector}
var \hyperlink{classOpenMesh_1_1VectorT_a5c9156d5a427cdecdc5282f83c2e346c}{sqrnorm} = vec.\hyperlink{classOpenMesh_1_1VectorT_a5c9156d5a427cdecdc5282f83c2e346c}{sqrnorm}() \textcolor{comment}{// Calculate the squared length of the vector}

var sprod = vec.sprod(vec)  \textcolor{comment}{//Compute scalar product with the vector and itself}

vec.\hyperlink{classOpenMesh_1_1VectorT_a067799f2aa7a99c8740b909ca13713c4}{normalize}()             \textcolor{comment}{// Normalize vector}

vec.zero()                  \textcolor{comment}{// Set all components of the vector to zero}

print(vec)                  \textcolor{comment}{// Output vector to the console}
\end{DoxyCode}
 \hypertarget{scripting_vector_type_4d}{}\section{Vector4d data type for scripting}\label{scripting_vector_type_4d}
The vector data type is corresponding to the Vec4d type in C++. The implementation of the scripting type is done in \hyperlink{classprototypeVec3d}{prototype\+Vec3d}.

You can use the following functions\+: 
\begin{DoxyCode}
var vec = \hyperlink{DataTypes_8hh_a705986e3da99b7e8e4e6bddf781558e7}{Vector4}(1,2,3,4)
var vec2 = \hyperlink{classOpenMesh_1_1VectorT}{Vector4}(10,20,30,4)

vec.multiply(0.5)           \textcolor{comment}{// Multiply vec with 0.5}
vec.add(vec2)               \textcolor{comment}{// Add vec2 to vec}
vec.sub(vec2)               \textcolor{comment}{// Subtract vec2 from vec}

var \hyperlink{classOpenMesh_1_1VectorT_afac3b9b6e93f8f47603f39ee387cb9a9}{norm}    = vec.\hyperlink{classOpenMesh_1_1VectorT_afac3b9b6e93f8f47603f39ee387cb9a9}{norm}()    \textcolor{comment}{// Calculate the length of the vector}
var \hyperlink{classOpenMesh_1_1VectorT_a5c9156d5a427cdecdc5282f83c2e346c}{sqrnorm} = vec.\hyperlink{classOpenMesh_1_1VectorT_a5c9156d5a427cdecdc5282f83c2e346c}{sqrnorm}() \textcolor{comment}{// Calculate the squared length of the vector}

var sprod = vec.sprod(vec)  \textcolor{comment}{//Compute scalar product with the vector and itself}

vec.\hyperlink{classOpenMesh_1_1VectorT_a067799f2aa7a99c8740b909ca13713c4}{normalize}()             \textcolor{comment}{// Normalize vector}

vec.zero()                  \textcolor{comment}{// Set all components of the vector to zero}

print(vec)                  \textcolor{comment}{// Output vector to the console}
\end{DoxyCode}
 \hypertarget{scripting_matrix_type}{}\section{Matrix data type used for scripting}\label{scripting_matrix_type}
The matrix type Matrix4x4 is used in the scripting language to handle matrix operations. The implementation of the type for scripting can be found in \hyperlink{classprototypeMatrix4x4}{prototype\+Matrix4x4} .

You can use the following functions\+: 
\begin{DoxyCode}
var matrix = \hyperlink{DataTypes_8hh_a2c834138d15bf416d68149d639c97ed8}{Matrix4x4}(1,0,0,1,
                       0,1,0,2,
                       0,0,1,3,
                       0,0,0,1 )  \textcolor{comment}{// Create a matrix that contains only a translation (1,2,3).}

var vec = Vector(1,2,3)  \textcolor{comment}{// Create a vector}

var vec2 = matrix.transform\_point(vec);  \textcolor{comment}{// Transforms a point by the given matrix (translation is
       included)}
var vec3 = matrix.transform\_vector(vec); \textcolor{comment}{// Transforms a vector by the given matrix (translation is
       omitted)}
\end{DoxyCode}
 