Skip to main content

optiSLang 3D Postprocessing Script API 2025 R1

ValueTypeBool Class Reference

Last update: 16.07.2025

Identifies a set of values as boolean and an associated set of optional attributes. 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 "true" -> 1.0 "false" -> 0.0 Capital letters are not supported. More...
 
string toString (number value) override
 Convert number value to its string representation 0.0 -> "false" not(0.0) -> "true". More...
 
eType type ()
 Get the Type of this ValueType.
 

Static Public Member Functions

static std::shared_ptr< ValueTypecreate (ValueTypeManager manager, string name, string description="Boolean type.", std::map< string, number > attributes={})
 Default destructor. More...
 

Detailed Description

Identifies a set of values as boolean and an associated set of optional attributes. 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.

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,
string  description = "Boolean type.",
std::map< string, number >  attributes = {} 
)
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.ValueTypeBool.create(manager, "my_bool_value_type")

Parameters
managerValueTypeManager where the shared resource is stored at.
nameUnique name of this ValueType.
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 "true" -> 1.0 "false" -> 0.0 Capital letters are not supported.

Parameters
strThe string to convert
Returns
The converted value
Note
Returns 0 if conversion fails.

Implements ValueType.

◆ toString()

string toString ( number  value)
overridevirtual

Convert number value to its string representation 0.0 -> "false" not(0.0) -> "true".

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

Implements ValueType.

Connect with Ansys