Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2024.
|
Provide various features to get paths, work on the tree view, adjust zoom and views, etc... More...
Enumerations | |
enum | SketchfabCategories { Animals_Pets = 0 , Architecture = 1 , Art_Abstract = 2 , Cars_Vehicles = 3 , Characters_Creatures = 4 , Cultural_Heritage_History = 5 , Electronic_Gadgets = 6 , Fashion_Style = 7 , Food_Drink = 8 , Furniture_Home = 9 , Music = 10 , Nature_Plants = 11 , News_Politics = 12 , People = 13 , Places_Travel = 14 , Science_Technology = 15 , Sports_Fitness = 16 , Weapons_Military = 17 } |
The available categories on Sketchfab. More... | |
enum | ViewDirEnum { AXIS_X = 0 , AXIS_Y = 1 , AXIS_Z = 2 , AXIS_REVERSE_X = 3 , AXIS_REVERSE_Y = 4 , AXIS_REVERSE_Z = 5 } |
The predefined view direction. More... | |
enum | ViewModeEnum { PERSPECTIVE = 0 , ORTHOGRAPHIC = 1 } |
The type of projection for the camera. More... | |
Functions | |
string | ApplicationPath () |
Return the application path. More... | |
ClearDoc () | |
Clear all the document and the trash. Can be useful to begin with a blank document. More... | |
string | ConvertNumberToString (number numberToConvert, string locale="") |
Convert the number to a string using the given locale settings. More... | |
Object | CopyDirContent (string srcDir, string destDir) |
Copy the content of one folder to another. All files and subfolders are recursively copied. More... | |
copydircontent (string srcDir, string destDir) | |
Copy the content of one folder to another. All files and subfolders are recursively copied. More... | |
Object | CreatePicture (string fileName, number height, number width, number background, number pointLineMagnification) |
Create a picture of the current scene. More... | |
string | CurrentDocPath () |
Return the current document path or an empty string if the current document has not been saved to disk. More... | |
string | CurrentScriptPath () |
Return the current script path of the first script evaluated (not the included files). More... | |
number | Execute (string program, Array< string > arguments) |
Execute an external program as a separate process and wait for completion. More... | |
Object | Export3DPDF (string fileName, Object exportSettings={}) |
Export the content of the 3D scene in a 3D PDF. More... | |
FlushDisplay () | |
Wait for all visible objects to be ready to be displayed. More... | |
Object | GetCameraDirection (SPoint targetPt=null) |
Get the camera direction from the camera position to the target pointed by the camera (the point the camera is looking at). More... | |
Object | GetCameraMode () |
Check whether the camera mode is in perspective or orthographic view. More... | |
Object | GetCameraPosition () |
Get the camera position. More... | |
Object | GetCoordSysTransf () |
Get the transformation matrix of the current local coordinate system if exists. More... | |
string | GetDoc (string iSymbolFullName) |
Get the documentation of the symbol name in argument. More... | |
string | GetListSeparator (string locale="") |
Get the separator list in the given locale settings. More... | |
string | GetOpenFileName (string caption, string filter, string defaultPath="") |
Show a dialog that ask the user to choose a file. More... | |
Array< string > | GetOpenFileNames (string caption, string filter, string defaultPath="") |
Show a dialog that ask the user to choose multiple files. More... | |
string | GetOpenFolder (string caption, string defaultPath="") |
Show a dialog that ask the user to choose a folder. More... | |
string | GetSaveFileName (string caption, string filter, string defaultPath="") |
Show a dialog that ask the user to choose a file that may not exist. More... | |
Object | GetScaleFactor () |
Get the scale factor permitting to convert the current document unit to mm. More... | |
string | GetThousandSeparator (string locale="") |
Get the separator used for the thousands in the given locale settings. More... | |
Include (string fileName) | |
To include another file. More... | |
Object | IsCameraLocked () |
Check whether the camera is locked (no rotation possible). More... | |
Object | KeepOnlyCurrentView () |
Keep only current view. More... | |
LockCamera (boolean lock) | |
Lock the camera (no rotation possible) More... | |
boolean | MkDir (string path) |
Creates a sub-directory at the given path. More... | |
boolean | mkdir (string path) |
Creates a sub-directory at the given path. More... | |
Object | OpenDoc (string fileName, boolean clearDoc=false, boolean applyUnit=false) |
Load a .3dr file, all the content of the file will be loaded in the current document. More... | |
Object | OpenRsh (string fileName, boolean clearDoc=false, boolean applyUnit=false) |
Load a .3dr file, all the content of the file will be loaded in the current document. More... | |
boolean | OpenUrl (string url) |
Open the given url in the appropriate Web browser for the user's desktop environment. More... | |
Print (any arg) | |
Print to output the argument. More... | |
print (any arg) | |
Print to output the argument. More... | |
Object | RemoveSplit () |
Remove split on current view. More... | |
Repaint () | |
Force repaint scene of the current document. More... | |
Object | SaveDoc (string fileName, boolean isOverWrite) |
Save a .3dr file. All the content of the current document will be saved. More... | |
Object | SaveRsh (string fileName, boolean isOverWrite) |
Save a .3dr file. All the content of the current document will be saved. More... | |
string | ScriptPath () |
Return the sample script path. More... | |
Object | SendToSketchFab (SComp compToExport, string token, string name, string description, string tags, SketchfabCategories category) |
Send a cloud or mesh in SketchFab platform. More... | |
Object | SetActiveView (number viewNumber) |
Change the active view. i.e set the focus to the view viewNumber. zero-based index. More... | |
SetCameraDirection (SVector dir, SVector up) | |
Update the direction of the camera. More... | |
SetCameraDirection (ViewDirEnum dir) | |
Update the direction of the camera to a predefined direction. More... | |
SetCameraMode (ViewModeEnum mode) | |
Set the camera in perspective or orthographic view. More... | |
SetCameraPosition (SPoint pos) | |
Update the position of the camera. More... | |
SetTextSize (number size) | |
Define character height inside the graphic scene. More... | |
SetViewDir (SVector dir, SVector up) | |
Update the direction of the view. More... | |
SetViewDir (ViewDirEnum dir) | |
Update the direction of the view to a predefined direction. More... | |
ShowOnly (Array< SComp > compsToShowOnly) | |
Show only input objects. More... | |
ShowOnlyInActiveView (Array< SComp > compsToShowOnly) | |
Show only input objects in the active view. More... | |
Sleep (number milliseconds) | |
Sleep the current script, this sleep function will not block interface. More... | |
Object | SplitHor () |
Split current view horizontally. More... | |
Object | SplitVert () |
Split current view vertically. More... | |
string | TempPath () |
Return the absolute path of the system's temporary directory. More... | |
number | ToLocaleNumber (string stringToConvert) |
Convert the string to number using the system's locale settings. More... | |
string | ToLocaleString (number numberToConvert) |
Convert a number in a string using the system's locale settings. More... | |
ZoomAll () | |
Do a zoom on all the visible SComp. More... | |
ZoomFactor (number factor) | |
Zoom the scene. More... | |
ZoomOn (Array< SComp > tableOfObjects, number milliseconds=0) | |
Do a zoom on some SComp. More... | |
Provide various features to get paths, work on the tree view, adjust zoom and views, etc...
The available categories on Sketchfab.
string ScriptUtil::ApplicationPath | ( | ) |
Return the application path.
ScriptUtil::ClearDoc | ( | ) |
Clear all the document and the trash. Can be useful to begin with a blank document.
string ScriptUtil::ConvertNumberToString | ( | number | numberToConvert, |
string | locale = "" |
||
) |
Convert the number to a string using the given locale settings.
numberToConvert | (number) The number to convert to string |
locale | (string) 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. |
Object ScriptUtil::CopyDirContent | ( | string | srcDir, |
string | destDir | ||
) |
Copy the content of one folder to another. All files and subfolders are recursively copied.
srcDir | (string) The source folder |
destDir | (string) The destination folder |
ret.ErrorCode | (number) The error code
|
ScriptUtil::copydircontent | ( | string | srcDir, |
string | destDir | ||
) |
Copy the content of one folder to another. All files and subfolders are recursively copied.
srcDir | (string) The source folder |
destDir | (string) The destination folder |
Object ScriptUtil::CreatePicture | ( | string | fileName, |
number | height, | ||
number | width, | ||
number | background, | ||
number | pointLineMagnification | ||
) |
Create a picture of the current scene.
fileName | (string) The image file name. |
height | (number) The height of of the image in pixel. Must be greater than 0. |
width | (number) The width of the image in pixels. Must be greater than 0. |
background | (number) Background type
|
pointLineMagnification | (number) Scaling factor for line width, point size and font size.
|
ret.ErrorCode | (number) The error code
|
string ScriptUtil::CurrentDocPath | ( | ) |
Return the current document path or an empty string if the current document has not been saved to disk.
string ScriptUtil::CurrentScriptPath | ( | ) |
Return the current script path of the first script evaluated (not the included files).
number ScriptUtil::Execute | ( | string | program, |
Array< string > | arguments | ||
) |
Execute an external program as a separate process and wait for completion.
Starts the 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.
program | (string) The program to execute. Either full path to .exe, or name of a program that is in the PATH%. |
arguments | (Array<string>) The arguments to pass to the program. |
-2 | The process cannot be started (program not found, missing dependencies, ...) |
-1 | The process crashed during its execution. |
Other | The exit code of the program. |
Object ScriptUtil::Export3DPDF | ( | string | fileName, |
Object | exportSettings = {} |
||
) |
Export the content of the 3D scene in a 3D PDF.
fileName | (string) The file path to write in |
exportSettings | (Object) The export options for 3DPDF
|
ret.ErrorCode | (number) The error code:
|
ScriptUtil::FlushDisplay | ( | ) |
Wait for all visible objects to be ready to be displayed.
This function is useful for objects like clouds which use an optimized structure computed asynchronously (in another thread).
Object ScriptUtil::GetCameraDirection | ( | SPoint | targetPt = null | ) |
Get the camera direction from the camera position to the target pointed by the camera (the point the camera is looking at).
targetPt | (SPoint) Optional point target in the camera plane. If the point is null the returned direction is the normal to camera plane. |
ret.ErrorCode | (number) The error code
|
ret.Vector | (SVector) The camera direction |
Object ScriptUtil::GetCameraMode | ( | ) |
Check whether the camera mode is in perspective or orthographic view.
ret.ErrorCode | (number) The error code
|
ret.Value | (number) The camera mode (ViewModeEnum) |
Object ScriptUtil::GetCameraPosition | ( | ) |
Get the camera position.
ret.ErrorCode | (number) The error code
|
ret.Point | (SPoint) The camera position |
Object ScriptUtil::GetCoordSysTransf | ( | ) |
Get the transformation matrix of the current local coordinate system if exists.
string ScriptUtil::GetDoc | ( | string | iSymbolFullName | ) |
Get the documentation of the symbol name in argument.
iSymbolFullName | (string) Name of the symbol. Like 'myModule.EnumName', 'myOtherModule.MyClass.MyFunction' or 'MyClassInMainModule' |
string ScriptUtil::GetListSeparator | ( | string | locale = "" | ) |
Get the separator list in the given locale settings.
locale | (string) 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 = "" |
||
) |
Show a dialog that ask the user to choose a file.
This is a convenience function that returns an existing file selected by the user. If the user presses Cancel, it returns a null string.
caption | (string) The name of the dialog box shown to the user. Example: "Select file to open" |
filter | (string) The name of the filter to show only relevant files to user. Example: "*.stl" or "*.stl; *.ply" or "Mesh files (*.stl; *.ply)" or "*.stl;;*.ply" |
defaultPath | (string) The path to a default folder. Example: "C:\Data\" |
Array< string > ScriptUtil::GetOpenFileNames | ( | string | caption, |
string | filter, | ||
string | defaultPath = "" |
||
) |
Show a dialog that ask the user to choose multiple files.
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.
caption | (string) The name of the dialog box shown to the user. Example: "Select file to open" |
filter | (string) The name of the filter to show only relevant files to user. Example: "*.stl" or "*.stl; *.ply" or "Mesh files (*.stl; *.ply)" or "*.stl;;*.ply" |
defaultPath | (string) The path to a default folder. Example: "C:\Data\" |
string ScriptUtil::GetOpenFolder | ( | string | caption, |
string | defaultPath = "" |
||
) |
Show a dialog that ask the user to choose a folder.
This is a convenience function that returns an existing folder selected by the user. If the user presses Cancel, it returns a null string.
caption | (string) The name of the dialog box shown to the user. Example: "Select folder to open" |
defaultPath | (string) The path to a default folder. Example: "C:\Data\" |
string ScriptUtil::GetSaveFileName | ( | string | caption, |
string | filter, | ||
string | defaultPath = "" |
||
) |
Show a dialog that ask the user to choose a file that may not exist.
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.
caption | (string) The name of the dialog box shown to the user. Example: "Select file to save" |
filter | (string) The name of the filter to show only relevant files to user. Example: "PTS files (*.pts)" |
defaultPath | (string) The path to a default folder. Example: "C:\Data\" |
Object ScriptUtil::GetScaleFactor | ( | ) |
Get the scale factor permitting to convert the current document unit to mm.
ret.Value | (number) The scale factor. |
string ScriptUtil::GetThousandSeparator | ( | string | locale = "" | ) |
Get the separator used for the thousands in the given locale settings.
locale | (string) The 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 another file.
fileName | (string) The file name path |
Object ScriptUtil::IsCameraLocked | ( | ) |
Check whether the camera is locked (no rotation possible).
ret.ErrorCode | (number) The error code
|
ret.Value | (boolean) Is the camera locked ? |
Object ScriptUtil::KeepOnlyCurrentView | ( | ) |
Keep only current view.
ret.ErrorCode | (number) The error code
|
ScriptUtil::LockCamera | ( | boolean | lock | ) |
Lock the camera (no rotation possible)
lock | (boolean) locking or unlocking the camera |
boolean ScriptUtil::MkDir | ( | string | path | ) |
Creates a sub-directory at the given path.
path | (string) The path of the directory to create. |
true | The directory has been created or already existed. |
false | An error occurred. |
boolean ScriptUtil::mkdir | ( | string | path | ) |
Creates a sub-directory at the given path.
path | (string) The path of the directory to create. |
true | The directory has been created or already existed. |
false | An error occurred. |
Object ScriptUtil::OpenDoc | ( | string | fileName, |
boolean | clearDoc = false , |
||
boolean | applyUnit = false |
||
) |
Load a .3dr file, all the content of the file will be loaded in the current document.
If you want to access an element in the script, you can use SComp.FromClick(), or SComp.FromName() function.
fileName | (string) The file path |
clearDoc | (boolean) Should the document be cleared before adding the content of the file? |
applyUnit | (boolean) True if we want to load the unit from the file to the current document. |
ret.ErrorCode | (number) The error code:
|
Object ScriptUtil::OpenRsh | ( | string | fileName, |
boolean | clearDoc = false , |
||
boolean | applyUnit = false |
||
) |
Load a .3dr file, all the content of the file will be loaded in the current document.
If you want to access an element in the script, you can use SComp.FromClick(), or SComp.FromName() function.
fileName | (string) The file path |
clearDoc | (boolean) Should the document be cleared before adding the content of the file? |
applyUnit | (boolean) True if we want to load the unit from the file to the current document. |
ret.ErrorCode | (number) The error code:
|
boolean ScriptUtil::OpenUrl | ( | string | url | ) |
Open the given url in the appropriate Web browser for the user's desktop environment.
url | (string) The url to open in a browser |
ScriptUtil::Print | ( | any | arg | ) |
Print to output the argument.
The object given in argument is converted to string and printed to output. An end of line is automatically added is not present at the end of text.
arg | (any) The argument to convert to string and add to the output |
ScriptUtil::print | ( | any | arg | ) |
Print to output the argument.
The object given in argument is converted to string and printed to output. An end of line is automatically added is not present at the end of text.
arg | (any) The argument to convert to string and add to the output |
Object ScriptUtil::RemoveSplit | ( | ) |
Remove split on current view.
ret.ErrorCode | (number) The error code:
|
ScriptUtil::Repaint | ( | ) |
Force repaint scene of the current document.
Object ScriptUtil::SaveDoc | ( | string | fileName, |
boolean | isOverWrite | ||
) |
Save a .3dr file. All the content of the current document will be saved.
If an object was created in the script and wasn't added to the document by calling the function AddToDoc(), this object will not be saved.
fileName | (string) The file path to save |
isOverWrite | (boolean) Overwrite if necessary, if the file exists already |
ret.ErrorCode | (number) The error code
|
Object ScriptUtil::SaveRsh | ( | string | fileName, |
boolean | isOverWrite | ||
) |
Save a .3dr file. All the content of the current document will be saved.
If an object was created in the script and wasn't added to the document by calling the function AddToDoc(), this object will not be saved.
fileName | (string) The file path to save |
isOverWrite | (boolean) Overwrite if necessary, if the file exists already |
ret.ErrorCode | (number) The error code
|
string ScriptUtil::ScriptPath | ( | ) |
Return the sample script path.
Object ScriptUtil::SendToSketchFab | ( | SComp | compToExport, |
string | token, | ||
string | name, | ||
string | description, | ||
string | tags, | ||
SketchfabCategories | category | ||
) |
Send a cloud or mesh in SketchFab platform.
compToExport | (SComp) The object (SPoly or SCloud) to export |
token | (string) The Sketchfab API token of your account |
name | (string) The name of the object |
description | (string) The description of the object |
tags | (string) The tags to describe your objects ("separated by ";") |
category | (SketchfabCategories) The category of your object,
|
ret.ErrorCode | (number) The error code
|
ret.String | (string) The link result |
Object ScriptUtil::SetActiveView | ( | number | viewNumber | ) |
Change the active view. i.e set the focus to the view viewNumber. zero-based index.
viewNumber | (number) The index of the view to activate |
ret.ErrorCode | (number) The error code:
|
Update the direction of the camera.
ScriptUtil::SetCameraDirection | ( | ViewDirEnum | dir | ) |
Update the direction of the camera to a predefined direction.
dir | (ViewDirEnum) The predefined direction to use (ViewDirEnum)
|
ScriptUtil::SetCameraMode | ( | ViewModeEnum | mode | ) |
Set the camera in perspective or orthographic view.
mode | (ViewModeEnum) The camera mode (Perspective or orthographic)
|
ScriptUtil::SetCameraPosition | ( | SPoint | pos | ) |
Update the position of the camera.
pos | (SPoint) The new camera position |
ScriptUtil::SetTextSize | ( | number | size | ) |
Define character height inside the graphic scene.
size | (number) The character size, between 5 and 99. |
Update the direction of the view.
ScriptUtil::SetViewDir | ( | ViewDirEnum | dir | ) |
Update the direction of the view to a predefined direction.
dir | (ViewDirEnum) The predefined direction to use (ViewDirEnum)
|
ScriptUtil::ShowOnly | ( | Array< SComp > | compsToShowOnly | ) |
Show only input objects.
compsToShowOnly | (Array<SComp>) The table of the objects to show only |
ScriptUtil::ShowOnlyInActiveView | ( | Array< SComp > | compsToShowOnly | ) |
Show only input objects in the active view.
compsToShowOnly | (Array<SComp>) The table of the objects to show only |
ScriptUtil::Sleep | ( | number | milliseconds | ) |
Sleep the current script, this sleep function will not block interface.
milliseconds | (number) The duration to wait (in milliseconds) |
Object ScriptUtil::SplitHor | ( | ) |
Split current view horizontally.
ret.ErrorCode | (number) The error code
|
Object ScriptUtil::SplitVert | ( | ) |
Split current view vertically.
ret.ErrorCode | (number) The error code
|
string ScriptUtil::TempPath | ( | ) |
Return the absolute path of the system's temporary directory.
number ScriptUtil::ToLocaleNumber | ( | string | stringToConvert | ) |
Convert the string to number using the system's locale settings.
stringToConvert | (string) The string to convert |
string ScriptUtil::ToLocaleString | ( | number | numberToConvert | ) |
Convert a number in a string using the system's locale settings.
numberToConvert | (number) The number to convert |
ScriptUtil::ZoomAll | ( | ) |
Do a zoom on all the visible SComp.
ScriptUtil::ZoomFactor | ( | number | factor | ) |
Zoom the scene.
factor | (number) The amount of zoom to apply |