IC Python API:RLPy RVariant

From Reallusion Wiki!
Revision as of 00:25, 14 April 2020 by Chuck (RL) (Talk | contribs)

Jump to: navigation, search
Main article: Modules.
Last modified: 04/14/2020

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.

 1 x = RLPy.RVariant(-10)
 2 print(x.GetType() == RLPy.RVariant.Int32)           #true
 3  
 4 f = x.ToFloat()
 5 print(f)                                            #-10.0
 6  
 7 y = RLPy.RVariant(10.0)
 8 print(y.GetType() == RLPy.RVariant.Float)           #true
 9  
10 n = x.ToInt32()
11 print(n)

Member Functions

GetType ( self )

Get type of this RVariant object.

Returns

Type of this RVariant object - int
  • RLPy.RVariant.Float
  • RLPy.RVariant.Int32
  • RLPy.RVariantUInt32
1 x = RLPy.RVariant(-10)
2 print(x.GetType() == RLPy.RVariant.Int32)           #true

ToFloat ( self, pSucess = None )

Convert to float.

See Also: ToInt32, ToUInt32

Parameters

pSucess [IN] success or not - bool

Returns

Value after conversion - float
1 x = RLPy.RVariant(-10) 
2 f = x.ToFloat()
3 print(f)

ToInt32 ( self, pSucess = None )

Convert to int32_t.

See Also: ToFloat, ToUInt32

Parameters

pSucess [IN] success or not - bool

Returns

Signed integer value after conversion - int32
1 f = RLPy.RVariant(-10.0) 
2 x = f.ToInt32()
3 print(x)

ToUInt32 ( self, pSucess = None )

Convert to uint32_t.

See Also: ToFloat, ToInt32

Parameters

pSucess [IN] success or not - bool

Returns

Unsigned integer value after conversion - uint32
1 f = RLPy.RVariant(10.0) 
2 x = f.ToUInt32()
3 print(x)