Skip to main content

optiSLang 3D Postprocessing Script API 2025 R1

ValueTypeEnum Class Reference

Last update: 16.07.2025

Identifies a set of values as an enumration of strings type and an associated set of optional attributes (for instance minimum and maximum value). It provides conversion routines between floating point and string representation. More...

Public Types

enum  eType { DOUBLE = 1, INT = 2, BOOL = 3, ENUM = 4 }
 Enumeration of all available value types. Returned by type() method. Used to identify from which derived class the shared base class ValueType object has been created.
 

Public Member Functions

string __str__ ()
 Function to allow printing instances of this class in python. More...
 
number attribute (string attribute)
 Returns the value of the given attribute. An attribute is a named value, to specify the behavior of the ValueType. For instance min/max. See ValueType derived classes for documentation of available attributes. More...
 
number attribute (string attribute, number default_value)
 Returns the value of the given attribute. Default value is returned if the attribute is undefined. An attribute is a named value, to specify the behavior of the ValueType. For instance min/max. See ValueType derived classes for documentation of available attributes. More...
 
bool attributeExists (string attribute)
 Check whether an attribute is defined.
 
string description ()
 Get the description of this ValueType.
 
bool eraseAttribute (string attribute)
 Removes an attribute. More...
 
string name ()
 Get the unique name of this ValueType.
 
bool operator!= (ValueType b)
 Returns false if both types have equal name, value type, attributes and description.
 
bool operator== (ValueType b)
 Returns true if both types have equal name, value type, attributes and description.
 
bool operator> (ValueType b)
 Sort by name.
 
 setAttribute (string attribute, number value)
 Define an attribute. Existing attributes are overwritten. More...
 
number toDouble (string str) override
 Convert string to floating point value Enumeration ["glass", "wood", "concrete"]: "glass" -> 0.0 "wood" -> 1.0 "concrete" -> 2.0. More...
 
string toString (number value) override
 Convert number value to its string representation Enumeration ["glass", "wood", "concrete"]: 0.0 -> "glass" -> 0.0 1.0 -> "wood" 2.0 -> "concrete" Always returns "glass" if value <= 0 Always returns "concrete" if value >= 2 Value is floored ( 0.6 -> "glass"). More...
 
eType type ()
 Get the Type of this ValueType.
 

Static Public Member Functions

static std::shared_ptr< ValueTypecreate (ValueTypeManager manager, string name, std::vector< string > strings, string description="Enumeration of strings type.")
 Default destructor. More...
 

Detailed Description

Identifies a set of values as an enumration of strings type and an associated set of optional attributes (for instance minimum and maximum value). It provides conversion routines between floating point and string representation.

See also
ValueTypeManager for Script example usage.
Note
Constructor is private, use the create() method to create new instances as a shared resource.class ValueTypeEnum : public ValueType

Member Function Documentation

◆ __str__()

string __str__ ( )
inherited

Function to allow printing instances of this class in python.

Returns
The unique name of this ValueType

◆ attribute() [1/2]

number attribute ( string  attribute)
inherited

Returns the value of the given attribute. An attribute is a named value, to specify the behavior of the ValueType. For instance min/max. See ValueType derived classes for documentation of available attributes.

Parameters
attributeAttribute to search for
Exceptions
Ifattribute is undefined

◆ attribute() [2/2]

number attribute ( string  attribute,
number  default_value 
)
inherited

Returns the value of the given attribute. Default value is returned if the attribute is undefined. An attribute is a named value, to specify the behavior of the ValueType. For instance min/max. See ValueType derived classes for documentation of available attributes.

Parameters
attributeAttribute to search for.
default_valueValue returned if attribute is undefined.

◆ create()

static std::shared_ptr<ValueType> create ( ValueTypeManager  manager,
string  name,
std::vector< string >  strings,
string  description = "Enumeration of strings type." 
)
static

Default destructor.

Create a new instances as a shared resources, which is stored at the ValueTypeManager. Static method, access in script: value_type = sos.ValueTypeDouble.create(manager, ["glass", "wood", "concrete"], "my_number_value_type") Sets the "min" attribute to 0 Sets the "max" attribute to (number of unique strings - 1)

Parameters
managerValueTypeManager where the shared resource is stored at.
nameUnique name of this ValueType.
stringsVector of strings the enumeration type consists of. Duplicate strings are omitted. The order of strings remains unchanged.
description[optional] Short description string of this ValueType
attributes[optional] Map of named number precision attributes
Returns
Shared resource of ValueType base class.

◆ eraseAttribute()

bool eraseAttribute ( string  attribute)
inherited

Removes an attribute.

Parameters
attributeThe attribute to remove
Returns
True if the attribute was removed. False if the attribute was undefined.

◆ setAttribute()

setAttribute ( string  attribute,
number  value 
)
inherited

Define an attribute. Existing attributes are overwritten.

Parameters
attributeName of the attribute.
valueValue of the attribute.

◆ toDouble()

number toDouble ( string  str)
overridevirtual

Convert string to floating point value Enumeration ["glass", "wood", "concrete"]: "glass" -> 0.0 "wood" -> 1.0 "concrete" -> 2.0.

Parameters
strThe string to convert
Returns
The converted value
Exceptions
ifthe string is not part of this enumeration type.

Implements ValueType.

◆ toString()

string toString ( number  value)
overridevirtual

Convert number value to its string representation Enumeration ["glass", "wood", "concrete"]: 0.0 -> "glass" -> 0.0 1.0 -> "wood" 2.0 -> "concrete" Always returns "glass" if value <= 0 Always returns "concrete" if value >= 2 Value is floored ( 0.6 -> "glass").

Parameters
valuethe number value to convert
Returns
The string representation of the converted value

Implements ValueType.

Connect with Ansys