Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2023.
Loading...
Searching...
No Matches
ScriptUtil Namespace Reference

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...
 
 SetCameraMode (ViewModeEnum mode)
 Set the camera in perspective or orthographic view. 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...
 

Detailed Description

Provide various features to get paths, work on the tree view, adjust zoom and views, etc...

Warning
To use the function from ScriptUtil, directly use the function name, without any namespace.
CreateGroup('MyGroup','Mesh Group');
ZoomAll()
Do a zoom on all the visible SComp.

Enumeration Type Documentation

◆ SketchfabCategories

The available categories on Sketchfab.

Enumerator
Animals_Pets 

Animals & Pets.

Architecture 

Architecture.

Art_Abstract 

Art & Abstract.

Cars_Vehicles 

Cars & Vehicles.

Characters_Creatures 

Characters & Creatures.

Cultural_Heritage_History 

Cultural Heritage & History.

Electronic_Gadgets 

Electronics & Gadgets.

Fashion_Style 

Fashion & Style.

Food_Drink 

Food & Drink.

Furniture_Home 

Furniture & Home.

Music 

Music.

Nature_Plants 

Nature & Plants.

News_Politics 

News & Politics.

People 

People.

Places_Travel 

Places & Travel.

Science_Technology 

Science & Technology.

Sports_Fitness 

Sports & Fitness.

Weapons_Military 

Weapons & Military.

◆ ViewDirEnum

The predefined view direction.

Enumerator
AXIS_X 

View on X axis, Z is up.

AXIS_Y 

View on Y axis, Z is up.

AXIS_Z 

View on Z axis, Y is up.

AXIS_REVERSE_X 

View on -X axis, Z is up.

AXIS_REVERSE_Y 

View on -Y axis, Z is up.

AXIS_REVERSE_Z 

View on -Z axis, Y is up.

◆ ViewModeEnum

The type of projection for the camera.

Enumerator
PERSPECTIVE 

Perspective camera.

ORTHOGRAPHIC 

Orthographic camera.

Function Documentation

◆ ApplicationPath()

string ScriptUtil::ApplicationPath ( )

Return the application path.

Returns
(string) The application path.

◆ ClearDoc()

ScriptUtil::ClearDoc ( )

Clear all the document and the trash. Can be useful to begin with a blank document.

◆ ConvertNumberToString()

string ScriptUtil::ConvertNumberToString ( number  numberToConvert,
string  locale = "" 
)

Convert the number to a string using the given locale settings.

Parameters
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.
Returns
(string) The number converted into localized string.

◆ CopyDirContent()

Object ScriptUtil::CopyDirContent ( string  srcDir,
string  destDir 
)

Copy the content of one folder to another. All files and subfolders are recursively copied.

Parameters
srcDir(string) The source folder
destDir(string) The destination folder
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ copydircontent()

ScriptUtil::copydircontent ( string  srcDir,
string  destDir 
)

Copy the content of one folder to another. All files and subfolders are recursively copied.

Deprecated:
This function is deprecated. Use CopyDirContent() instead.
Parameters
srcDir(string) The source folder
destDir(string) The destination folder

◆ CreatePicture()

Object ScriptUtil::CreatePicture ( string  fileName,
number  height,
number  width,
number  background,
number  pointLineMagnification 
)

Create a picture of the current scene.

Parameters
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
  • 0: Same background as on screen.
  • 1: Always white.
pointLineMagnification(number) Scaling factor for line width, point size and font size.
  • 0: Same as on screen
  • >1: Greater.
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ CurrentDocPath()

string ScriptUtil::CurrentDocPath ( )

Return the current document path or an empty string if the current document has not been saved to disk.

Returns
(string) The current document path.

◆ CurrentScriptPath()

string ScriptUtil::CurrentScriptPath ( )

Return the current script path of the first script evaluated (not the included files).

Returns
(string) The current script path.

◆ Execute()

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.

print(Execute("C:\\LaunchPythonScript.bat", ["test_1337", "3.1415"]));
number Execute(string program, Array< string > arguments)
Execute an external program as a separate process and wait for completion.
print(any arg)
Print to output the argument.
Warning
When you write a '\' in string you need to double it '\\' or use '/' instead. Pay especially attention to this when writing file paths in your scripts.
var path = 'C:/Point.asc'; // valid syntax
var path = 'C:\\Point.asc'; // valid syntax
var path = 'C:\Point.asc'; // invalid syntax
Parameters
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.
Returns
The exit code of the child process, or -1 or -2 if there was a problem during execution of the process.
Return values
-2The process cannot be started (program not found, missing dependencies, ...)
-1The process crashed during its execution.
OtherThe exit code of the program.

◆ Export3DPDF()

Object ScriptUtil::Export3DPDF ( string  fileName,
Object  exportSettings = {} 
)

Export the content of the 3D scene in a 3D PDF.

Note
This function will add the suffix "pdf" at the end of the filename, if the user didn't do it.
Warning
When you write a '\' in string you need to double it '\\' or use '/' instead. Pay especially attention to this when writing file paths in your scripts.
var path = 'C:/Point.asc'; // valid syntax
var path = 'C:\\Point.asc'; // valid syntax
var path = 'C:\Point.asc'; // invalid syntax
var labelDir = SVector.New(0,0,1)
var exportOption = {
basePdfFilePath : 'C:/MyBasicPdfFile.pdf',
pageIndex : -2, //insert at last page
labelDirection : labelDir,
labelColorRed : 1,
labelColorGreen : 0,
labelColorBlue : 0,
contourLineTextDistance : 15,
contourLineColorRed : 0,
contourLineColorGreen : 1,
contourLineColorBlue : 0,
}
var res = Export3DPDF('C:/MyPdfFile.pdf', exportOption); // insert the scene at the last page of C:/MyBasicPdfFile.pdf and save the final file as C:/MyPdfFile.pdf
Allow the use of the mathematical vector object.
Definition: Reshaper.h:1994
static SVector New()
Empty constructor.
Object Export3DPDF(string fileName, Object exportSettings={})
Export the content of the 3D scene in a 3D PDF.
Parameters
fileName(string) The file path to write in
exportSettings(Object) The export options for 3DPDF
  • basePdfFilePath (String): The path of the existing pdf to append (can be equal to FileName)
  • pageIndex (Number): The index of the page before the inserted page. -1: insert at first page (default), -2: insert at last page, 0..N: insert after page n
  • labelDirection (SVector): The direction of the line of label
  • labelColorRed (Number): The red color of label, between [0-1]
  • labelColorGreen (Number): The green color of label, between [0-1]
  • labelColorBlue (Number): The blue color of label, between [0-1]
  • contourLineTextDistance (Number): The distance between text of contourLine
  • contourLineColorRed (Number): The red color of contourLine, between [0-1]
  • contourLineColorGreen (Number): The green color of contourLine, between [0-1]
  • contourLineColorBlue (Number): THe blue color of contourLine, between [0-1]
Return values
ret.ErrorCode(number) The error code:
  • 0: No error
  • 1: An error occurred
  • 2: The file basePdfFilePath does not exist !
  • 3: A color value is not in the right range

◆ FlushDisplay()

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).

◆ GetCameraDirection()

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).

Note
This vector is not normalized.
With an ortho camera, the direction doesn't depend on the point.
Parameters
targetPt(SPoint) Optional point target in the camera plane. If the point is null the returned direction is the normal to camera plane.
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred
ret.Vector(SVector) The camera direction

◆ GetCameraMode()

Object ScriptUtil::GetCameraMode ( )

Check whether the camera mode is in perspective or orthographic view.

Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred
ret.Value(number) The camera mode (ViewModeEnum)

◆ GetCameraPosition()

Object ScriptUtil::GetCameraPosition ( )

Get the camera position.

Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred
ret.Point(SPoint) The camera position

◆ GetCoordSysTransf()

Object ScriptUtil::GetCoordSysTransf ( )

Get the transformation matrix of the current local coordinate system if exists.

var point = SPoint.New(1, 2, 3); // Coordinates in WCS
var res = GetCoordSysTransf();
if(res.ErrorCode == 0) // Check if there is a local coordinate system
point.ApplyTransformation(res.MatW2L); // Now point is (1, 2, 3) in UCS
Provide point edition and creation methods.
Definition: Reshaper.h:6179
static SPoint New()
Default constructor to create an empty new SPoint. X = Y = Z = 0.
Object GetCoordSysTransf()
Get the transformation matrix of the current local coordinate system if exists.
Return values
ret.ErrorCode(number) The error code:
  • 0: No error
  • 1: No local coordinate system is activated.
ret.MatW2L(SMatrix) The transformation matrix from World to Local coordinate system.
ret.MatL2W(SMatrix) The transformation matrix from Local to World coordinate system.

◆ GetDoc()

string ScriptUtil::GetDoc ( string  iSymbolFullName)

Get the documentation of the symbol name in argument.

Parameters
iSymbolFullName(string) Name of the symbol. Like 'myModule.EnumName', 'myOtherModule.MyClass.MyFunction' or 'MyClassInMainModule'
Returns
(string) If symbol found a string containing the symbol documentation, else an empty string

◆ GetListSeparator()

string ScriptUtil::GetListSeparator ( string  locale = "")

Get the separator list in the given locale settings.

Parameters
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
Returns
(string) The list separator. If the decimal separator of the locale settings is '.' the list separator is ',' else it is ';'.

◆ GetOpenFileName()

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.

Parameters
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\"
Returns
(string) The path of the chosen file or an empty string if no file has been selected.

◆ GetOpenFileNames()

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.

Parameters
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\"
Returns
(Array<string>) An array of string containing the paths of the chosen files, empty if no file has been selected.

◆ GetOpenFolder()

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.

Parameters
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\"
Returns
(string) The path of the chosen folder or an empty string if no folder has been selected.

◆ GetSaveFileName()

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.

Parameters
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\"
Returns
(string) The path of the chosen file or an empty string if no file has been selected.

◆ GetScaleFactor()

Object ScriptUtil::GetScaleFactor ( )

Get the scale factor permitting to convert the current document unit to mm.

Return values
ret.Value(number) The scale factor.

◆ GetThousandSeparator()

string ScriptUtil::GetThousandSeparator ( string  locale = "")

Get the separator used for the thousands in the given locale settings.

Parameters
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.
Returns
(string) The thousand separator.

◆ Include()

ScriptUtil::Include ( string  fileName)

To include another file.

Parameters
fileName(string) The file name path

◆ IsCameraLocked()

Object ScriptUtil::IsCameraLocked ( )

Check whether the camera is locked (no rotation possible).

Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred
ret.Value(boolean) Is the camera locked ?

◆ KeepOnlyCurrentView()

Object ScriptUtil::KeepOnlyCurrentView ( )

Keep only current view.

Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ LockCamera()

ScriptUtil::LockCamera ( boolean  lock)

Lock the camera (no rotation possible)

Parameters
lock(boolean) locking or unlocking the camera

◆ MkDir()

boolean ScriptUtil::MkDir ( string  path)

Creates a sub-directory at the given path.

Warning
Only one directory level is created, the parent directory must already exist.
Parameters
path(string) The path of the directory to create.
Return values
trueThe directory has been created or already existed.
falseAn error occurred.

◆ mkdir()

boolean ScriptUtil::mkdir ( string  path)

Creates a sub-directory at the given path.

Warning
Only one directory level is created, the parent directory must already exist.
Deprecated:
This function is deprecated. Use MkDir() instead.
Parameters
path(string) The path of the directory to create.
Return values
trueThe directory has been created or already existed.
falseAn error occurred.

◆ OpenDoc()

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.

Warning
When you write a '\' in string you need to double it '\\' or use '/' instead. Pay especially attention to this when writing file paths in your scripts.
var path = 'C:/Point.asc'; // valid syntax
var path = 'C:\\Point.asc'; // valid syntax
var path = 'C:\Point.asc'; // invalid syntax
Parameters
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.
Return values
ret.ErrorCode(number) The error code:
  • 0: No error
  • 1: An exception occurred, or irrecoverable error or file does not exist

◆ OpenRsh()

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.

Warning
When you write a '\' in string you need to double it '\\' or use '/' instead. Pay especially attention to this when writing file paths in your scripts.
var path = 'C:/Point.asc'; // valid syntax
var path = 'C:\\Point.asc'; // valid syntax
var path = 'C:\Point.asc'; // invalid syntax
Deprecated:
This function is deprecated. Use OpenDoc() instead.
Parameters
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.
Return values
ret.ErrorCode(number) The error code:
  • 0: No error
  • 1: An exception occurred, or irrecoverable error or file does not exist

◆ OpenUrl()

boolean ScriptUtil::OpenUrl ( string  url)

Open the given url in the appropriate Web browser for the user's desktop environment.

Parameters
url(string) The url to open in a browser
Returns
(boolean) True on success, false otherwise.

◆ Print()

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.

Parameters
arg(any) The argument to convert to string and add to the output

◆ print()

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.

Parameters
arg(any) The argument to convert to string and add to the output

◆ RemoveSplit()

Object ScriptUtil::RemoveSplit ( )

Remove split on current view.

Deprecated:
This function is deprecated.
Return values
ret.ErrorCode(number) The error code:
  • 0: No error
  • 1: No split to remove: only 1 view in the document
  • 2: Other error

◆ Repaint()

ScriptUtil::Repaint ( )

Force repaint scene of the current document.

◆ SaveDoc()

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.

Note
This function will add the suffix "3dr" at the end of the filename, if the user didn't do it.
Warning
When you write a '\' in string you need to double it '\\' or use '/' instead. Pay especially attention to this when writing file paths in your scripts.
var path = 'C:/Point.asc'; // valid syntax
var path = 'C:\\Point.asc'; // valid syntax
var path = 'C:\Point.asc'; // invalid syntax
Parameters
fileName(string) The file path to save
isOverWrite(boolean) Overwrite if necessary, if the file exists already
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ SaveRsh()

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.

Note
This function will add the suffix "3dr" at the end of the filename, if the user didn't do it.
Warning
When you write a '\' in string you need to double it '\\' or use '/' instead. Pay especially attention to this when writing file paths in your scripts.
var path = 'C:/Point.asc'; // valid syntax
var path = 'C:\\Point.asc'; // valid syntax
var path = 'C:\Point.asc'; // invalid syntax
Deprecated:
This function is deprecated. Use SaveDoc() instead.
Parameters
fileName(string) The file path to save
isOverWrite(boolean) Overwrite if necessary, if the file exists already
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ ScriptPath()

string ScriptUtil::ScriptPath ( )

Return the sample script path.

Returns
(string) The path to sample script folder.

◆ SendToSketchFab()

Object ScriptUtil::SendToSketchFab ( SComp  compToExport,
string  token,
string  name,
string  description,
string  tags,
SketchfabCategories  category 
)

Send a cloud or mesh in SketchFab platform.

See also
SketchfabCategories
Parameters
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,
  • Animals_Pets: Animals & Pets
  • Architecture: Architecture
  • Art_Abstract: Art & Abstract
  • Cars_Vehicles: Cars & Vehicles
  • Characters_Creatures: Characters & Creatures
  • Cultural_Heritage_History: Cultural Heritage & History
  • Electronic_Gadgets: Electronics & Gadgets
  • Fashion_Style: Fashion & Style
  • Food_Drink: Food & Drink
  • Furniture_Home: Furniture & Home
  • Music: Music
  • Nature_Plants: Nature & Plants
  • News_Politics: News & Politics
  • People: People
  • Places_Travel: Places & Travel
  • Science_Technology: Science & Technology
  • Sports_Fitness: Sports & Fitness
  • Weapons_Military: Weapons & Military
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred
ret.String(string) The link result

◆ SetActiveView()

Object ScriptUtil::SetActiveView ( number  viewNumber)

Change the active view. i.e set the focus to the view viewNumber. zero-based index.

Parameters
viewNumber(number) The index of the view to activate
Return values
ret.ErrorCode(number) The error code:
  • 0: No error
  • 1: The view with the given index doesn't exist

◆ SetCameraMode()

ScriptUtil::SetCameraMode ( ViewModeEnum  mode)

Set the camera in perspective or orthographic view.

See also
ViewModeEnum
Parameters
mode(ViewModeEnum) The camera mode (Perspective or orthographic)
  • PERSPECTIVE: Perspective camera
  • ORTHOGRAPHIC: Orthographic camera

◆ SetTextSize()

ScriptUtil::SetTextSize ( number  size)

Define character height inside the graphic scene.

Parameters
size(number) The character size, between 5 and 99.

◆ SetViewDir() [1/2]

ScriptUtil::SetViewDir ( SVector  dir,
SVector  up 
)

Update the direction of the view.

Note
The up direction is only taken into account when the direction is collinear to the Z axis. Most of the time it is overridden to be Z.
Parameters
dir(SVector) The new view direction
up(SVector) The new up direction

◆ SetViewDir() [2/2]

ScriptUtil::SetViewDir ( ViewDirEnum  dir)

Update the direction of the view to a predefined direction.

See also
ViewDirEnum
Parameters
dir(ViewDirEnum) The predefined direction to use (ViewDirEnum)
  • AXIS_X: View on X axis, Z is up
  • AXIS_Y: View on Y axis, Z is up
  • AXIS_Z: View on Z axis, Y is up
  • AXIS_REVERSE_X: View on -X axis, Z is up
  • AXIS_REVERSE_Y: View on -Y axis, Z is up
  • AXIS_REVERSE_Z: View on -Z axis, Y is up

◆ ShowOnly()

ScriptUtil::ShowOnly ( Array< SComp compsToShowOnly)

Show only input objects.

Parameters
compsToShowOnly(Array<SComp>) The table of the objects to show only

◆ ShowOnlyInActiveView()

ScriptUtil::ShowOnlyInActiveView ( Array< SComp compsToShowOnly)

Show only input objects in the active view.

Parameters
compsToShowOnly(Array<SComp>) The table of the objects to show only

◆ Sleep()

ScriptUtil::Sleep ( number  milliseconds)

Sleep the current script, this sleep function will not block interface.

Parameters
milliseconds(number) The duration to wait (in milliseconds)

◆ SplitHor()

Object ScriptUtil::SplitHor ( )

Split current view horizontally.

Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ SplitVert()

Object ScriptUtil::SplitVert ( )

Split current view vertically.

Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ TempPath()

string ScriptUtil::TempPath ( )

Return the absolute path of the system's temporary directory.

Returns
(string) The path to system's temporary folder.

◆ ToLocaleNumber()

number ScriptUtil::ToLocaleNumber ( string  stringToConvert)

Convert the string to number using the system's locale settings.

Parameters
stringToConvert(string) The string to convert
Returns
(number) The converted number, or 0 if the string didn't represent a number.

◆ ToLocaleString()

string ScriptUtil::ToLocaleString ( number  numberToConvert)

Convert a number in a string using the system's locale settings.

Parameters
numberToConvert(number) The number to convert
Returns
(string) The converted string.

◆ ZoomAll()

ScriptUtil::ZoomAll ( )

Do a zoom on all the visible SComp.

◆ ZoomFactor()

ScriptUtil::ZoomFactor ( number  factor)

Zoom the scene.

Parameters
factor(number) The amount of zoom to apply

◆ ZoomOn()

ScriptUtil::ZoomOn ( Array< SComp tableOfObjects,
number  milliseconds = 0 
)

Do a zoom on some SComp.

Parameters
tableOfObjects(Array<SComp>) THe table of objects to zoom on
milliseconds(number) The time to do the zoom on (in milliseconds)