IC8 Python API:RLPy RVariant

From Reallusion Wiki!
Jump to: navigation, search

Description

This class acts like an union for common data types. A RVariant object holds a single value of a specified type T at a time. You can use GetType to find out what type the variant holds, and get its value by one of the ToT() functions, e.g. ToInt32. Currently, there are two types supported: float and int.

Constructor & Destructor

__init__ (self, *args)

Initializes a new variant instance.

Parameters

  • args

Member Functions

GetType (self)

Get type of this RVariant object.

Sample code

Demonstrates calls to `RLPy.RVariant.GetType`, `RLPy.RVariant.ToBool`, and `RLPy.RVariant.ToString` using the example's inputs.

import RLPy

def run_script():
    number = RLPy.RVariant(-10)
    number_type = number.GetType()
    as_bool = number.ToBool()
    text = RLPy.RVariant("sample text")
    text_type = text.GetType()
    as_text = text.ToString()
    return (number_type, as_bool, text_type, as_text)

ToBool (self, pSuccess=None)

Converts to bool.

Parameters

  • pSuccess

Sample code

Demonstrates calls to `RLPy.RVariant.GetType`, `RLPy.RVariant.ToBool`, and `RLPy.RVariant.ToString` using the example's inputs.

import RLPy

def run_script():
    number = RLPy.RVariant(-10)
    number_type = number.GetType()
    as_bool = number.ToBool()
    text = RLPy.RVariant("sample text")
    text_type = text.GetType()
    as_text = text.ToString()
    return (number_type, as_bool, text_type, as_text)

ToFloat (self, pSucess=None)

Convert to float. See Also: ToInt32, ToUInt32

Parameters

  • pSucess

Sample code

Calls `RLPy.RVariant.ToFloat` with the inputs shown in the example.

def run_script():
    import RLPy
    x = RLPy.RVariant(-10) 
    f = x.ToFloat()
    print(f)

ToInt32 (self, pSucess=None)

Convert to int32_t. See Also: ToFloat, ToUInt32

Parameters

  • pSucess

Sample code

Calls `RLPy.RVariant.ToInt32` with the inputs shown in the example.

def run_script():
    import RLPy
    f = RLPy.RVariant(-10.0) 
    x = f.ToInt32()
    print(x)

ToString (self, pSuccess=None)

Converts to string.

Parameters

  • pSuccess

Sample code

Demonstrates calls to `RLPy.RVariant.GetType`, `RLPy.RVariant.ToBool`, and `RLPy.RVariant.ToString` using the example's inputs.

import RLPy

def run_script():
    number = RLPy.RVariant(-10)
    number_type = number.GetType()
    as_bool = number.ToBool()
    text = RLPy.RVariant("sample text")
    text_type = text.GetType()
    as_text = text.ToString()
    return (number_type, as_bool, text_type, as_text)

ToUInt32 (self, pSucess=None)

Convert to uint32_t. See Also: ToFloat, ToInt32

Parameters

  • pSucess

Sample code

Calls `RLPy.RVariant.ToUInt32` with the inputs shown in the example.

def run_script():
    import RLPy
    f = RLPy.RVariant(10.0) 
    x = f.ToUInt32()
    print(x)

Properties

thisown

Indicates whether this SWIG proxy owns the underlying C++ object.

Constants

Bool

Float

InValid

Int32

String

UInt32