ScriptUtil is a various toolbox with features to get paths, work on the tree view, adjust zoom and views, etc.
.
More...
Enumerations | |
enum | SketchFabCategories { Animals_Creatures , Architecture , Cars_Vehicles , Characters , Cultural_Heritage , Gaming , Places_Scenes , Product_Technology , Weapons } |
enum | ViewDirEnum { AXIS_X , AXIS_Y , AXIS_Z , AXIS_REVERSE_X , AXIS_REVERSE_Y , AXIS_REVERSE_Z } |
Set of the view direction. More... | |
enum | ViewModeEnum { PERSPECTIVE , ORTHOGRAPHIC } |
Set of the view direction. More... | |
Functions | |
String | ApplicationPath () |
This function will return the application path. More... | |
ClearDoc () | |
To clear all the document and the trash. Can be useful to begin with a blank document. More... | |
Array | ConvertNumberToString (Number iNumberToConvert, String iLocale="") |
Convert the number to a string using the given locale settings. More... | |
copydircontent (String DirOrg, String DirDest) | |
Copy the content of one folder to another all files and subfolders, recursively. More... | |
Array | CreatePicture (String FileName, Number Height, Number Width, Number Background, Number TextHeightCoef) |
To create a picture of the current scene. . More... | |
String | CurrentScriptPath () |
This function will return the current script path of the first script evaluated (not the include files) More... | |
Number | Execute (String Program, Array< String > Arguments) |
Starts the program program with the arguments arguments in a new process, waits for it to finish, and then returns the exit code of the process. Any data the new process writes to the console is forwarded to the calling process. If the process cannot be started, -2 is returned. If the process crashes, -1 is returned. Otherwise, the process' exit code is returned. More... | |
Array | Export3DPDF (String FileName, Array exportSettings=Array()) |
To export the content of the 3D scene in a 3D PDF. . More... | |
FlushDisplay () | |
Blocking function waiting for all visible objects to be ready to be displayed. This function is useful for objects like clouds which used an optimized structure computed asynchronously (in another thread). More... | |
SVector | GetCameraDirection (SPoint iTargetPt) |
To get the camera direction from the camera position to the target pointed by the camera (the point the camera is looking at). This vector is not normalized. More... | |
ViewModeEnum | GetCameraMode () |
To check whether the camera mode is in perspective or orthographic view. More... | |
SPoint | GetCameraPosition () |
To get the camera position. More... | |
Array | GetCoordSysTransf () |
Get the transformation matrix of the current local coordinate system if exists. More... | |
Array | GetListSeparator (String iLocale="") |
Function to get the separator list in the given locale settings. More... | |
String | GetOpenFileName (String Caption, String Filter, String DefaultPath="") |
This is a convenience function that returns an existing file selected by the user. If the user presses Cancel, it returns a null string. More... | |
QStringList | GetOpenFileNames (String Caption, String Filter, String DefaultPath="") |
This is a convenience function that returns a table of existing files selected by the user. If the user presses Cancel, it returns an empty table. More... | |
String | GetOpenFolder (String Caption, String DefaultPath="") |
This is a convenience function that returns an existing folder selected by the user. If the user presses Cancel, it returns a null string. More... | |
String | GetSaveFileName (String Caption, String Filter, String DefaultPath="") |
This is a convenience function that will return a file name selected by the user. The file does not have to exist. If the user presses Cancel, it returns a null string. More... | |
Number | GetScaleFactor () |
Get the scale factor permitting to convert the current document unit to mm. More... | |
Array | GetThousandSeparator (String iLocale="") |
Function to get the separator used for the thousands in the given locale settings. More... | |
Include (String FileName) | |
To include other javascript files. More... | |
Boolean | IsCameraLocked () |
To check whether the camera is locked (no rotation possible) More... | |
KeepOnlyCurrentView () | |
Keep only current view. More... | |
LockCamera (Boolean lock) | |
Lock the camera (no rotation possible) More... | |
Boolean | mkdir (String DirName) |
Creates a sub-directory called DirName. Returns true on success; otherwise returns false. If the directory already exists when this function is called, it will return false. More... | |
Array | OpenDoc (String FileName, Boolean ClearDoc, Boolean ApplyUnit) |
To load an .3dr file, all the content of the file will be load in the current document. If you want to access to an element in the script, you can use FromClick(), or FromName() function. More... | |
Array | OpenRsh (String FileName, Boolean ClearDoc, Boolean ApplyUnit) |
To load an .3dr file, all the content of the file will be load in the current document. If you want to access to an element in the script, you can use FromClick(), or FromName() function. More... | |
Boolean | OpenUrl (String Url) |
Opens the given url in the appropriate Web browser for the user's desktop environment, and returns true if successful; otherwise returns false. More... | |
RemoveSplit () | |
Remove split on current view. More... | |
Repaint () | |
To force Repaint scene of the current document. More... | |
Array | SaveDoc (String FileName, Boolean IsOverWrite) |
To save an .3dr file, all the content of the current document will be save. If an object was created in the script and wasn't add to the document by calling the function AddToDoc(), this object will not be saved. More... | |
Array | SaveRsh (String FileName, Boolean IsOverWrite) |
To save an .3dr file, all the content of the current document will be save. If an object was created in the script and wasn't add to the document by calling the function AddToDoc(), this object will not be saved. More... | |
String | ScriptPath () |
This function will return the sample script path. More... | |
Array | SendToSketchFab (Array< SComp > CompToExport, String Token, String Name, String Description, String Tags, SketchFabCategories Category) |
Send a cloud or mesh in SketchFab platform. . More... | |
SetActiveView (uint viewNumber,) | |
Change the active view. i.e set the focus to the view viewNumber. zero-based index. More... | |
SetCameraMode (ViewModeEnum Mode) | |
To set the camera in perspective or orthographic view. More... | |
SetTextSize (Number Size) | |
To define character height inside the graphic scene. More... | |
SetViewDir (SVector Dir, SVector Up) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Update the direction of the view. More... | |
SetViewDir (ViewDirEnum Dir) | |
Update the direction of the view. More... | |
ShowOnly (Array< SComp > compsToShowOnly) | |
Show only input objects. More... | |
ShowOnlyInActiveView (Array< SComp > compsToShowOnly) | |
Show only input objects in the specified view. More... | |
Sleep (Number Milliseconds) | |
To sleep the current script, this sleep function will not block interface. More... | |
SplitHor () | |
Split current view horizontally. More... | |
SplitVert () | |
Split current view vertically. More... | |
String | TempPath () |
Returns the absolute path of the system's temporary directory. More... | |
Number | ToLocaleNumber (String StringToConvert) |
to convert the string to number using the system's locale settings More... | |
String | ToLocaleString (Number NumberToConvert) |
to convert a number in a string using the system's locale settings More... | |
trayCreate () | |
Create tray icon Hide current windows Show tray icon. More... | |
trayRemove () | |
Display application windows Hide tray icon. More... | |
ZoomAll () | |
To make a zoom on all the visible SComp. More... | |
ZoomFactor (Number factor) | |
Zoom the scene. More... | |
ZoomOn (Array< SComp > TableOfObjects, Number milliseconds) | |
To make a zoom on some SComp. More... | |
ScriptUtil is a various toolbox with features to get paths, work on the tree view, adjust zoom and views, etc.
.
String ScriptUtil::ApplicationPath | ( | ) |
This function will return the application path.
ScriptUtil::ClearDoc | ( | ) |
To clear all the document and the trash.
Can be useful to begin with a blank document.
Array ScriptUtil::ConvertNumberToString | ( | Number | iNumberToConvert, |
String | iLocale = "" |
||
) |
Convert the number to a string using the given locale settings.
The | number converted into local string. |
[in] | iNumberToConvert | The number to convert to string |
[in] | iLocale | Name of the locale language and country settings, in the form language-COUNTRY using the corresponding ISO codes for example: "en-US" for United-States English, "en-GB" for Great-Britain English, "fr-FR" for French If empty, the locale settings of the computer are used |
ScriptUtil::copydircontent | ( | String | DirOrg, |
String | DirDest | ||
) |
Copy the content of one folder to another all files and subfolders, recursively.
Array ScriptUtil::CreatePicture | ( | String | FileName, |
Number | Height, | ||
Number | Width, | ||
Number | Background, | ||
Number | TextHeightCoef | ||
) |
To create a picture of the current scene.
.
Array.ErrorCode | The error code:
|
[in] | FileName | image file name |
[in] | Height | number of pixels height. If <0, this number is adjusted to insure the picture is no too large for photo editor |
[in] | Width | number of pixels width. If <0, this number is adjusted to insure the picture is no too large for photo editor |
[in] | Background | Background type
|
[in] | TextHeightCoef | Text height coef multiplication factor
|
String ScriptUtil::CurrentScriptPath | ( | ) |
This function will return the current script path of the first script evaluated (not the include files)
Number ScriptUtil::Execute | ( | String | Program, |
Array< String > | Arguments | ||
) |
Starts the program program with the arguments arguments in a new process, waits for it to finish, and then returns the exit code of the process. Any data the new process writes to the console is forwarded to the calling process. If the process cannot be started, -2 is returned. If the process crashes, -1 is returned. Otherwise, the process' exit code is returned.
Array ScriptUtil::Export3DPDF | ( | String | FileName, |
Array | exportSettings = Array() |
||
) |
To export the content of the 3D scene in a 3D PDF.
.
Array.ErrorCode | The error code:
|
[in] | FileName | The file path to write in |
[in] | exportSettings | data structure containing export options for 3DPDF
|
ScriptUtil::FlushDisplay | ( | ) |
Blocking function waiting for all visible objects to be ready to be displayed. This function is useful for objects like clouds which used an optimized structure computed asynchronously (in another thread).
To get the camera direction from the camera position to the target pointed by the camera (the point the camera is looking at). This vector is not normalized.
[in] | iTargetPt | Optional point target in the camera plane. If the point is null the returned direction is the normal to camera plane. |
ViewModeEnum ScriptUtil::GetCameraMode | ( | ) |
To check whether the camera mode is in perspective or orthographic view.
SPoint ScriptUtil::GetCameraPosition | ( | ) |
To get the camera position.
Array ScriptUtil::GetCoordSysTransf | ( | ) |
Get the transformation matrix of the current local coordinate system if exists.
Array.ErrorCode | The error code:
|
Array.MatW2L | The transformation matrix from World to Local coordinate system. |
Array.MatL2W | The transformation matrix from Local to World coordinate system. |
Array ScriptUtil::GetListSeparator | ( | String | iLocale = "" | ) |
Function to get the separator list in the given locale settings.
The | separator list. If the decimal separator of the locale settings is '.' the list separator is ',' else it is ';'. |
[in] | iLocale | Name of the locale language and country settings, in the form language-COUNTRY using the corresponding ISO codes for example: "en-US" for United-States English, "en-GB" for Great-Britain English, "fr-FR" for French If empty, the locale settings of the computer are used |
String ScriptUtil::GetOpenFileName | ( | String | Caption, |
String | Filter, | ||
String | DefaultPath = "" |
||
) |
This is a convenience function that returns an existing file selected by the user. If the user presses Cancel, it returns a null string.
[in] | Caption | name of the dialog box shown to the user. Example: "Select file to open" |
[in] | Filter | name of the filter to show only relevant files to user. Example: "*.stl" or "*.stl; *.ply" or "Mesh files (*.stl; *.ply)" or "*.stl;;*.ply" |
[in] | DefaultPath | path to a default folder. Example: "C:\\Data\\" |
QStringList ScriptUtil::GetOpenFileNames | ( | String | Caption, |
String | Filter, | ||
String | DefaultPath = "" |
||
) |
This is a convenience function that returns a table of existing files selected by the user. If the user presses Cancel, it returns an empty table.
[in] | Caption | name of the dialog box shown to the user. Example: "Select file to open" |
[in] | Filter | name of the filter to show only relevant files to user. Example: "*.stl" or "*.stl; *.ply" or "Mesh files (*.stl; *.ply)" or "*.stl;;*.ply" |
[in] | DefaultPath | path to a default folder. Example: "C:\\Data\\" |
String ScriptUtil::GetOpenFolder | ( | String | Caption, |
String | DefaultPath = "" |
||
) |
This is a convenience function that returns an existing folder selected by the user. If the user presses Cancel, it returns a null string.
[in] | Caption | name of the dialog box shown to the user. Example: "Select folder to open" |
[in] | DefaultPath | path to a default folder. Example: "C:\\Data\\" |
String ScriptUtil::GetSaveFileName | ( | String | Caption, |
String | Filter, | ||
String | DefaultPath = "" |
||
) |
This is a convenience function that will return a file name selected by the user. The file does not have to exist. If the user presses Cancel, it returns a null string.
[in] | Caption | name of the dialog box shown to the user. Example: "Select file to save" |
[in] | Filter | name of the filter to show only relevant files to user. Example: "PTS files (*.pts)" |
[in] | DefaultPath | path to a default folder. Example: "C:\\Data\\" |
Number ScriptUtil::GetScaleFactor | ( | ) |
Get the scale factor permitting to convert the current document unit to mm.
Array ScriptUtil::GetThousandSeparator | ( | String | iLocale = "" | ) |
Function to get the separator used for the thousands in the given locale settings.
The | separator. |
[in] | iLocale | Name of the locale language and country settings, in the form language-COUNTRY using the corresponding ISO codes for example: "en-US" for United-States English, "en-GB" for Great-Britain English, "fr-FR" for French If empty, the locale settings of the computer are used |
ScriptUtil::Include | ( | String | FileName | ) |
To include other javascript files.
FileName | The file name path |
Boolean ScriptUtil::IsCameraLocked | ( | ) |
To check whether the camera is locked (no rotation possible)
ScriptUtil::KeepOnlyCurrentView | ( | ) |
Keep only current view.
0 | OK, no error |
1 | other error |
ScriptUtil::LockCamera | ( | Boolean | lock | ) |
Lock the camera (no rotation possible)
[in] | lock | locking or unlocking the camera |
Boolean ScriptUtil::mkdir | ( | String | DirName | ) |
Creates a sub-directory called DirName. Returns true on success; otherwise returns false. If the directory already exists when this function is called, it will return false.
Array ScriptUtil::OpenDoc | ( | String | FileName, |
Boolean | ClearDoc, | ||
Boolean | ApplyUnit | ||
) |
To load an .3dr file, all the content of the file will be load in the current document.
If you want to access to an element in the script, you can use FromClick(), or FromName() function.
Array.ErrorCode | The error code:
|
[in] | FileName | The file path |
[in] | ClearDoc | True if we must clear the current document before adding the new element in the document, else false. you can use ClearDoc() instead |
[in] | ApplyUnit | True if we want to load the unit from the file to the current document. |
Array ScriptUtil::OpenRsh | ( | String | FileName, |
Boolean | ClearDoc, | ||
Boolean | ApplyUnit | ||
) |
To load an .3dr file, all the content of the file will be load in the current document.
If you want to access to an element in the script, you can use FromClick(), or FromName() function.
Array.ErrorCode | The error code:
|
[in] | FileName | The file path |
[in] | ClearDoc | True if we must clear the current document before adding the new element in the document, else false. you can use ClearDoc() instead |
[in] | ApplyUnit | True if we want to load the unit from the file to the current document. |
Boolean ScriptUtil::OpenUrl | ( | String | Url | ) |
Opens the given url in the appropriate Web browser for the user's desktop environment, and returns true if successful; otherwise returns false.
ScriptUtil::RemoveSplit | ( | ) |
Remove split on current view.
0 | OK, no error |
1 | no split to remove: only 1 view in the document |
2 | other error |
ScriptUtil::Repaint | ( | ) |
To force Repaint scene of the current document.
Array ScriptUtil::SaveDoc | ( | String | FileName, |
Boolean | IsOverWrite | ||
) |
To save an .3dr file, all the content of the current document will be save.
If an object was created in the script and wasn't add to the document by calling the function AddToDoc(), this object will not be saved.
Array.ErrorCode | The error code:
|
[in] | FileName | The file path to save |
[in] | IsOverWrite | Overwrite if necessary, if the file exist already |
Array ScriptUtil::SaveRsh | ( | String | FileName, |
Boolean | IsOverWrite | ||
) |
To save an .3dr file, all the content of the current document will be save.
If an object was created in the script and wasn't add to the document by calling the function AddToDoc(), this object will not be saved.
Array.ErrorCode | The error code:
|
[in] | FileName | The file path to save |
[in] | IsOverWrite | Overwrite if necessary, if the file exist already |
String ScriptUtil::ScriptPath | ( | ) |
This function will return the sample script path.
Array ScriptUtil::SendToSketchFab | ( | Array< SComp > | CompToExport, |
String | Token, | ||
String | Name, | ||
String | Description, | ||
String | Tags, | ||
SketchFabCategories | Category | ||
) |
Send a cloud or mesh in SketchFab platform. .
Array.String | The link result |
Array.ErrorCode | The error code:
|
[in] | CompToExport | table of object to export |
[in] | Token | API Token to your account |
[in] | Name | Name of the object |
[in] | Description | Description of the object |
[in] | Tags | Tags to describe the object |
[in] | Category | Category to your object. Please refer to SketchFab categories to choose |
ScriptUtil::SetActiveView | ( | uint | viewNumber | ) |
Change the active view. i.e set the focus to the view viewNumber. zero-based index.
0 | OK, no error |
1 | viewNumber is not present |
[in] | viewNumber | number of view to activate |
ScriptUtil::SetCameraMode | ( | ViewModeEnum | Mode | ) |
To set the camera in perspective or orthographic view.
[in] | Mode | Perspective or orthographic |
ScriptUtil::SetTextSize | ( | Number | Size | ) |
To define character height inside the graphic scene.
[in] | Size | 8 <= Size <= 22 |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Update the direction of the view.
[in] | Dir | Direction to set |
[in] | Up | Up direction |
ScriptUtil::SetViewDir | ( | ViewDirEnum | Dir | ) |
Update the direction of the view.
[in] | Dir | Use a predefined direction |
ScriptUtil::ShowOnly | ( | Array< SComp > | compsToShowOnly | ) |
Show only input objects.
[in] | compsToShowOnly | table of object to show only |
ScriptUtil::ShowOnlyInActiveView | ( | Array< SComp > | compsToShowOnly | ) |
Show only input objects in the specified view.
[in] | compsToShowOnly | table of object to show only |
ScriptUtil::Sleep | ( | Number | Milliseconds | ) |
To sleep the current script, this sleep function will not block interface.
Milliseconds | Duration to wait (in milliseconds) |
ScriptUtil::SplitHor | ( | ) |
Split current view horizontally.
0 | OK, no error |
1 | other error |
ScriptUtil::SplitVert | ( | ) |
Split current view vertically.
0 | OK, no error |
1 | other error |
String ScriptUtil::TempPath | ( | ) |
Returns the absolute path of the system's temporary directory.
Number ScriptUtil::ToLocaleNumber | ( | String | StringToConvert | ) |
to convert the string to number using the system's locale settings
String ScriptUtil::ToLocaleString | ( | Number | NumberToConvert | ) |
to convert a number in a string using the system's locale settings
ScriptUtil::trayCreate | ( | ) |
Create tray icon
Hide current windows
Show tray icon.
0 | OK, no error |
1 | other error |
ScriptUtil::trayRemove | ( | ) |
Display application windows
Hide tray icon.
0 | OK, no error |
1 | other error |
ScriptUtil::ZoomAll | ( | ) |
To make a zoom on all the visible SComp.
ScriptUtil::ZoomFactor | ( | Number | factor | ) |
Zoom the scene.
[in] | factor |