Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2024.
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. More...
 
Object AddBoolean (Object params)
 Add a new line for boolean to the Dialog. More...
 
Object AddChoices (Object params)
 Add a new line for choices to the Dialog. More...
 
Object AddFloat (Object params)
 Add a new line for float number to the Dialog. More...
 
boolean AddImage (string imgPath, number width=-1, number height=-1, boolean keepRatio=true)
 Adds a new image to the Dialog. More...
 
Object AddInt (Object params)
 Add a new line for integer to the Dialog. More...
 
Object AddLength (Object params)
 Add a new line for length to the Dialog. More...
 
 AddLine (string label, boolean isInput, Object labParams={}, number defaultInput=0)
 Adds a new line to the Dialog. More...
 
 AddLine (string label, boolean isInput, Object labParams={}, number defaultInput=0)
 Adds a new line to the Dialog. More...
 
 AddLine (string label, boolean isInput, Object labParams={}, string defaultInput="")
 Adds a new line to the Dialog. More...
 
 AddOutput (string label, string output, Object labParams={}, Object outParams={})
 Adds a new output line to the Dialog. More...
 
Object AddPoint (Object params)
 Add a new line for SPoint to the Dialog. More...
 
 AddText (string message, EMessageSeverity severity=SDialog.Instruction)
 Add a new text line in the Dialog. More...
 
Object AddTextField (Object params)
 Add a new line for text field to the Dialog. More...
 
Object AddVector (Object params)
 Add a new line for SVector to the Dialog. More...
 
 BeginGroup (string groupName)
 Start a new group in the Dialog. More...
 
Object Execute ()
 Executes the dialog box. More...
 
Object Run ()
 Executes the dialog box. More...
 
 SDialog (string title="Dialog")
 Dialog constructor. More...
 
 SetButtons (Array< string > values)
 Set buttons at the end of the Dialog. More...
 
 SetHeader (string description, string imagePath="", number maxHeight=150)
 Add a description and a logo at the beginning of the Dialog. More...
 
string toString ()
 Get the type of the variable. More...
 

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. More...
 
static Message (string message, EMessageSeverity severity=SDialog.Instruction, string title="Dialog")
 Create a dialog to display a message. More...
 
static SDialog New (string title="Dialog")
 Dialog constructor. More...
 
static boolean Question (string question, string title="Dialog")
 Create a dialog to ask a question. More...
 

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
Provide simple dialog creation methods.
Definition: Reshaper.h:1381
Object AddAngle(Object params)
Add a new line for angle to the Dialog.
static SDialog New(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;
Object AddBoolean(Object params)
Add a new line for boolean to the Dialog.
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,
});
var res = myDialog.Run();
var choicesValue = res.myChoices;
Object AddChoices(Object params)
Add a new line for choices to the Dialog.
@ RadioButtons
To display as radio button.
Definition: Reshaper.h:1404
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;
Object AddFloat(Object params)
Add a new line for float number to the Dialog.
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;
Object AddInt(Object params)
Add a new line for integer to the Dialog.
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");
Object AddLength(Object params)
Add a new line for length to the Dialog.
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

◆ AddLine() [1/3]

SDialog::AddLine ( string  label,
boolean  isInput,
Object  labParams = {},
number  defaultInput = 0 
)

Adds a new line to the Dialog.

Either a simple line with a single label, or also with a text input field. The resulting inputs are then returned by the Execute() method

Deprecated:
This function is deprecated. Use AddBoolean(), AddTextField()... instead.
Parameters
label(string) Label text
isInput(boolean) Should the line include a text input field?
labParams(Object) Label text parameters, as associative array. Available key parameters:
  • align (string): text alignment
  • size (number): text size in points (pt)
  • color (string): text color. You can specify a color using different formats (like with CSS):either #rgb / #rrggbb / the color name (same names as CSS color names).
  • css (string): Additional custom CSS code
defaultInput(number) Default text if input field

◆ AddLine() [2/3]

SDialog::AddLine ( string  label,
boolean  isInput,
Object  labParams = {},
number  defaultInput = 0 
)

Adds a new line to the Dialog.

Either a simple line with a single label, or also with a text input field. The resulting inputs are then returned by the Execute() method

Deprecated:
This function is deprecated. Use AddBoolean(), AddTextField()... instead.
Parameters
label(string) Label text
isInput(boolean) Should the line include a text input field?
labParams(Object) Label text parameters, as associative array. Available key parameters:
  • align (string): text alignment
  • size (number): text size in points (pt)
  • color (string): text color. You can specify a color using different formats (like with CSS):either #rgb / #rrggbb / the color name (same names as CSS color names).
  • css (string): Additional custom CSS code
defaultInput(number) Default text if input field

◆ AddLine() [3/3]

SDialog::AddLine ( string  label,
boolean  isInput,
Object  labParams = {},
string  defaultInput = "" 
)

Adds a new line to the Dialog.

Either a simple line with a single label, or also with a text input field. The resulting inputs are then returned by the Execute() method

Deprecated:
This function is deprecated. Use AddBoolean(), AddTextField()... instead.
Parameters
label(string) Label text
isInput(boolean) Should the line include a text input field?
labParams(Object) Label text parameters, as associative array. Available key parameters:
  • align (string): text alignment
  • size (number): text size in points (pt)
  • color (string): text color. You can specify a color using different formats (like with CSS):either #rgb / #rrggbb / the color name (same names as CSS color names).
  • css (string): Additional custom CSS code
defaultInput(string) Default text if input field

◆ AddOutput()

SDialog::AddOutput ( string  label,
string  output,
Object  labParams = {},
Object  outParams = {} 
)

Adds a new output line to the Dialog.

Deprecated:
This function is deprecated. Use AddBoolean(), AddTextField()... instead.
Parameters
label(string) Label text
output(string) Output text
labParams(Object) Label text parameters, as associative array. Available key parameters:
  • align (string): text alignment
  • size (number): text size in points (pt)
  • color (string): text color. You can specify a color using different formats (like with CSS):either #rgb / #rrggbb / the color name (same names as CSS color names).
  • css (string): Additional custom CSS code
outParams(Object) Output text parameters (same usage as with labParams)
  • align (string): text alignment
  • size (number): text size in points (pt)
  • color (string): text color. You can specify a color using different formats (like with CSS):either #rgb / #rrggbb / the color name (same names as CSS color names).
  • css (string): Additional custom CSS code

◆ 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.
Object AddPoint(Object params)
Add a new line for SPoint to the Dialog.
Provide matrix with 3 lines and 4 columns to make any transformation.
Definition: Reshaper.h:2019
static SMatrix FromActiveCS()
Return the matrix associated to the active coordinate system.
Provide point edition and creation methods.
Definition: Reshaper.h:6761
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;
Object AddTextField(Object params)
Add a new line for text field to the Dialog.
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)");
Object AddVector(Object params)
Add a new line for SVector to the Dialog.
Allow the use of the mathematical vector object.
Definition: Reshaper.h:2531
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

◆ Execute()

Object SDialog::Execute ( )

Executes the dialog box.

Deprecated:
This function is deprecated. Use Run() instead.
Return values
ret.ErrorCode(number) The error code
  • 0: The OK button was pressed
  • 1: The Dialog was canceled / closed or an error occurred
ret.InputTbl(Array<string>) The resulting user input strings (in the same order as the input lines)

◆ 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"...
SetButtons(Array< string > values)
Set buttons at the end of the Dialog.
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