Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2025.
Loading...
Searching...
No Matches
SDialog Class Reference

Provide simple dialog creation methods. More...

Public Types

enum  ChoiceRepresentationMode { RadioButtons = 0 , ComboBox = 1 }
 The representation. More...
 
enum  EMessageSeverity {
  Info = 0 , Warning = 1 , Error = 2 , Success = 3 ,
  Instruction = 4
}
 The severity of the message. More...
 

Public Member Functions

Object AddAngle (Object params)
 Add a new line for angle to the Dialog.
 
Object AddBoolean (Object params)
 Add a new line for boolean to the Dialog.
 
Object AddChoices (Object params)
 Add a new line for choices to the Dialog.
 
Object AddFloat (Object params)
 Add a new line for float number to the Dialog.
 
boolean AddImage (string imgPath, number width=-1, number height=-1, boolean keepRatio=true)
 Adds a new image to the Dialog.
 
Object AddInt (Object params)
 Add a new line for integer to the Dialog.
 
Object AddLength (Object params)
 Add a new line for length to the Dialog.
 
Object AddPoint (Object params)
 Add a new line for SPoint to the Dialog.
 
 AddText (string message, EMessageSeverity severity=SDialog.Instruction)
 Add a new text line in the Dialog.
 
Object AddTextField (Object params)
 Add a new line for text field to the Dialog.
 
Object AddVector (Object params)
 Add a new line for SVector to the Dialog.
 
 BeginGroup (string groupName)
 Start a new group in the Dialog.
 
Object Run ()
 Executes the dialog box.
 
 SDialog (string title="Dialog")
 Dialog constructor.
 
 SetButtons (Array< string > values)
 Set buttons at the end of the Dialog.
 
 SetHeader (string description, string imagePath="", number maxHeight=150)
 Add a description and a logo at the beginning of the Dialog.
 
string toString ()
 Get the type of the variable.
 

Static Public Member Functions

static Object Message (string message, Array< string > buttons, EMessageSeverity severity=SDialog.Instruction, string title="Dialog")
 Create a dialog to display a message with custom buttons.
 
static Message (string message, EMessageSeverity severity=SDialog.Instruction, string title="Dialog")
 Create a dialog to display a message.
 
static SDialog New (string title="Dialog")
 Dialog constructor.
 
static boolean Question (string question, string title="Dialog")
 Create a dialog to ask a question.
 

Detailed Description

Provide simple dialog creation methods.

See also Creating Custom Form page for details on how to use this class.

Member Enumeration Documentation

◆ ChoiceRepresentationMode

The representation.

Enumerator
RadioButtons 

To display as radio button.

ComboBox 

To display as combo box.

◆ EMessageSeverity

The severity of the message.

Enumerator
Info 

To display an information.

Warning 

To display a warning.

Error 

To display an error.

Success 

To display a success message.

Instruction 

To display an instruction.

Constructor & Destructor Documentation

◆ SDialog()

SDialog::SDialog ( string title = "Dialog")

Dialog constructor.

Parameters
title(string) Window title

Member Function Documentation

◆ AddAngle()

Object SDialog::AddAngle ( Object params)

Add a new line for angle to the Dialog.

var myDialog = SDialog.New("Script title");
myDialog.AddAngle({
'id': 'myAngle',
'name': 'Angle value',
'tooltip': "A little description",
'value': 90,
'saveValue': false,
'readOnly': true,
'min': 0,
'max': 180
});
var res = myDialog.Run();
var angleValue = res.myAngle; // in degree
SDialog(string title="Dialog")
Dialog constructor.
Parameters
params(Object) Parameters as associative array. Available key parameters:
  • id (string): The ID
  • name (string): The display name
  • tooltip (string): The tooltip
  • value (number): The value to display (in degree)
  • saveValue (boolean): To save the value
  • readOnly (boolean): If the value is read only or not
  • min (number): To specify a minimum value (in degree)
  • max (number): To specify a maximum value (in degree)
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Empty name

◆ AddBoolean()

Object SDialog::AddBoolean ( Object params)

Add a new line for boolean to the Dialog.

var myDialog = SDialog.New("Script title");
myDialog.AddBoolean({
'id': 'myBoolean',
'name': 'Boolean value',
'tooltip': "A little description",
'value': true,
'saveValue': false,
'readOnly': true
});
var res = myDialog.Run();
var booleanValue = res.myBoolean;
Parameters
params(Object) Parameters as associative array. Available key parameters:
  • id (string): The ID
  • name (string): The display name
  • tooltip (string): The tooltip
  • value (boolean): The value to display
  • saveValue (boolean): To save the value
  • readOnly (boolean): If the value is read only or not
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Empty name

◆ AddChoices()

Object SDialog::AddChoices ( Object params)

Add a new line for choices to the Dialog.

var myDialog = SDialog.New("Script title");
myDialog.AddChoices({
'id': 'myChoices',
'name': 'All choices values',
'tooltip': "A little description",
'choices': ['option A', 'option B', 'option C', 'option D'],
'value': 0, // correspond to 'option A'
'saveValue': false,
'readOnly': true,
'style': SDialog.RadioButtons
});
var res = myDialog.Run();
var choicesValue = res.myChoices;
Parameters
params(Object) Parameters as associative array. Available key parameters:
  • id (string): The ID
  • name (string): The display name
  • choices (Array<string>): The list of available choices
  • tooltip (string): The tooltip
  • value (number): The value to display (index of choice starting at 0)
  • saveValue (boolean): To save the value
  • readOnly (boolean): If the value is read only or not
  • style (ChoiceRepresentationMode): The representation mode
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Empty name
  • 2: Invalid choices

◆ AddFloat()

Object SDialog::AddFloat ( Object params)

Add a new line for float number to the Dialog.

var myDialog = SDialog.New("Script title");
myDialog.AddFloat({
'id': 'myNumber',
'name': 'Number value',
'tooltip': "A little description",
'value': 10.5,
'saveValue': false,
'readOnly': true,
'min': -99.9,
'max': 100
});
var res = myDialog.Run();
var numberValue = res.myNumber;
Parameters
params(Object) Parameters as associative array. Available key parameters:
  • id (string): The ID
  • name (string): The display name
  • tooltip (string): The tooltip
  • value (number): The value to display
  • saveValue (boolean): To save the value
  • readOnly (boolean): If the value is read only or not
  • min (number): To specify a minimum value
  • max (number): To specify a maximum value
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Empty name

◆ AddImage()

boolean SDialog::AddImage ( string imgPath,
number width = -1,
number height = -1,
boolean keepRatio = true )

Adds a new image to the Dialog.

Supported formats include PNG, JPG, JPEG, BMP and more.

Parameters
imgPath(string) Image path
width(number) Image width. Negative to ignore.
height(number) Image height. Negative to ignore.
keepRatio(boolean) Should the original size ratio be respected?
Returns
(boolean) true if success, false if failure

◆ AddInt()

Object SDialog::AddInt ( Object params)

Add a new line for integer to the Dialog.

var myDialog = SDialog.New("Script title");
myDialog.AddInt({
'id': 'myNumber',
'name': 'Number value',
'tooltip': "A little description",
'value': 5,
'saveValue': false,
'readOnly': true,
'min': -100,
'max': 100
});
var res = myDialog.Run();
var numberValue = res.myNumber;
Parameters
params(Object) Parameters as associative array. Available key parameters:
  • id (string): The ID
  • name (string): The display name
  • tooltip (string): The tooltip
  • value (number): The value to display
  • saveValue (boolean): To save the value
  • readOnly (boolean): If the value is read only or not
  • min (number): To specify a minimum value
  • max (number): To specify a maximum value
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Empty name

◆ AddLength()

Object SDialog::AddLength ( Object params)

Add a new line for length to the Dialog.

var scaleFactor = GetScaleFactor().Value; //from document unit to mm
var myDialog = SDialog.New("Script title");
myDialog.AddLength({
'id': 'myLength',
'name': 'Length value',
'tooltip': "A little description",
'value': 5,
'saveValue': true,
'readOnly': true,
'min': 0.0001,
'max': 1000
});
var res = myDialog.Run();
var lengthInDocumentUnit = res.myLength; // in document unit
var lengthInmm = lengthInDocumentUnit*scaleFactor; //in mm
print(lengthInDocumentUnit);
print(lengthInmm+"mm");
Note
By default, a length is unsigned. It is possible to manipulate a signed length by defining a negative minimum value (for example, -Number.MAX_VALUE).
Parameters
params(Object) Parameters as associative array. Available key parameters:
  • id (string): The ID
  • name (string): The display name
  • tooltip (string): The tooltip
  • value (number): The value to display (in document unit)
  • saveValue (boolean): To save the value
  • readOnly (boolean): If the value is read only or not
  • min (number): To specify a minimum value (in document unit)
  • max (number): To specify a maximum value (in document unit)
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Empty name

◆ AddPoint()

Object SDialog::AddPoint ( Object params)

Add a new line for SPoint to the Dialog.

var currentUCSMat = SMatrix.FromActiveCS();
var myDialog = SDialog.New("Script title");
myDialog.AddPoint({
'id': 'myPoint',
'name': 'Point value',
'tooltip': "A little description",
'value': SPoint.New(10, 20, 30),
'saveValue': false,
'readOnly': true
});
var res = myDialog.Run();
var pointInWCS = res.myPoint; // point is given in WCS
var pointInUCS = SPoint.New(pointInWCS);
pointInUCS.ApplyTransformation(currentUCSMat); // same point given in UCS
print(pointInWCS.ValuesToString()+"(WCS)");
print(pointInUCS.ValuesToString()+"(UCS)");
ApplyTransformation(SMatrix matrix)
Apply a geometric transformation to the current object by making a product with the given matrix.
Provide matrix with 3 lines and 4 columns to make any transformation.
Definition Reshaper.h:1900
static SMatrix FromActiveCS()
Return the matrix associated to the active coordinate system.
Provide point edition and creation methods.
Definition Reshaper.h:7025
static SPoint New()
Default constructor to create an empty new SPoint. X = Y = Z = 0.
Parameters
params(Object) Parameters as associative array. Available key parameters:
  • id (string): The ID
  • name (string): The display name
  • tooltip (string): The tooltip
  • value (SPoint): The value to display (given in WCS)
  • saveValue (boolean): To save the value
  • readOnly (boolean): If the value is read only or not
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Empty name

◆ AddText()

SDialog::AddText ( string message,
EMessageSeverity severity = SDialog.Instruction )

Add a new text line in the Dialog.

Parameters
message(string) The message to display
severity(EMessageSeverity) The severity of the message

◆ AddTextField()

Object SDialog::AddTextField ( Object params)

Add a new line for text field to the Dialog.

var myDialog = SDialog.New("Script title");
myDialog.AddTextField({
'id': 'myString',
'name': 'String value',
'tooltip': "A little description",
'value': 'another value',
'saveValue': false,
'readOnly': true,
'canBeEmpty': false
});
var res = myDialog.Run();
var stringValue = res.myString;
Parameters
params(Object) Parameters as associative array. Available key parameters:
  • id (string): The ID
  • name (string): The display name
  • tooltip (string): The tooltip
  • value (string): The value to display
  • saveValue (boolean): To save the value
  • readOnly (boolean): If the value is read only or not
  • canBeEmpty (boolean): If the string can be empty or not
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Empty name

◆ AddVector()

Object SDialog::AddVector ( Object params)

Add a new line for SVector to the Dialog.

var currentUCSMat = SMatrix.FromActiveCS();
var myDialog = SDialog.New("Script title");
myDialog.AddVector({
'id': 'myVector',
'name': 'Vector value',
'tooltip': "A little description",
'value': SVector.New(0, 0, 1), //in WCS
'saveValue': false,
'readOnly': true
});
var res = myDialog.Run();
var vectorInWCS = res.myVector; // vector is given in WCS
var vectorInUCS = SVector.New(vectorInWCS);
vectorInUCS.ApplyTransformation(currentUCSMat); // same vector given in UCS
print(vectorInWCS.ValuesToString()+"(WCS)");
print(vectorInUCS.ValuesToString()+"(UCS)");
Allow the use of the mathematical vector object.
Definition Reshaper.h:2412
static SVector New()
Empty constructor.
ApplyTransformation(SMatrix matrix)
Apply a geometric transformation to the current SVector by making a product with the given matrix.
Parameters
params(Object) Parameters as associative array. Available key parameters:
  • id (string): The ID
  • name (string): The display name
  • tooltip (string): The tooltip
  • value (SVector): The value to display (given in WCS)
  • saveValue (boolean): To save the value
  • readOnly (boolean): If the value is read only or not
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Empty name

◆ BeginGroup()

SDialog::BeginGroup ( string groupName)

Start a new group in the Dialog.

Parameters
groupName(string) The title of the group

◆ Message() [1/2]

static Object SDialog::Message ( string message,
Array< string > buttons,
EMessageSeverity severity = SDialog.Instruction,
string title = "Dialog" )
static

Create a dialog to display a message with custom buttons.

Parameters
message(string) The message to display
buttons(Array<string>) The buttons to add
severity(EMessageSeverity) The severity of the message
title(string) Window title
Return values
ret.ErrorCode(number) The index of the clicked button.
  • -1: The dialog has been closed
  • 0: The 1st button has been pressed
  • n: The (n+1)th button has been pressed

◆ Message() [2/2]

static SDialog::Message ( string message,
EMessageSeverity severity = SDialog.Instruction,
string title = "Dialog" )
static

Create a dialog to display a message.

Parameters
message(string) The message to display
severity(EMessageSeverity) The severity of the message
title(string) Window title

◆ New()

static SDialog SDialog::New ( string title = "Dialog")
static

Dialog constructor.

Parameters
title(string) Window title
Returns
(SDialog) The new SDialog.

◆ Question()

static boolean SDialog::Question ( string question,
string title = "Dialog" )
static

Create a dialog to ask a question.

Parameters
question(string) The question to display
title(string) Window title
Returns
(boolean) True : Yes, False : No.

◆ Run()

Object SDialog::Run ( )

Executes the dialog box.

Return values
ret.ErrorCode(number) The index of the clicked button. By default if SDialog.SetButtons is not used:
  • -1: The dialog has been closed
  • 0: The OK button has been pressed
  • 1: The Cancel button has been pressed
  • n: The (n+1)th button has been pressed

◆ SetButtons()

SDialog::SetButtons ( Array< string > values)

Set buttons at the end of the Dialog.

var myDialog = SDialog.New("Script title");
myDialog.SetButtons(["Button A", "Button B", "Button C"]);
var res = myDialog.Run();
var buttonId = res.ErrorCode; // = 0 for "Button A", 1 for "Button B"...
Parameters
values(Array<string>) The list of name to use as button

◆ SetHeader()

SDialog::SetHeader ( string description,
string imagePath = "",
number maxHeight = 150 )

Add a description and a logo at the beginning of the Dialog.

Parameters
description(string) The description of the script
imagePath(string) The path to the image to use
maxHeight(number) Max height of the image

◆ toString()

string SDialog::toString ( )

Get the type of the variable.

Returns
(string) The type name