Difference between revisions of "IC Python API:RLPy RVariant"
From Reallusion Wiki!
Chuck (RL) (Talk | contribs) (Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} == Detailed Description == The class acts like a union for the most common data types. A RVariant object holds a sin...") |
Chuck (RL) (Talk | contribs) m |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{TOC}} | {{TOC}} | ||
{{Parent|IC_Python_API:RL_Python_Modules|Modules}} | {{Parent|IC_Python_API:RL_Python_Modules|Modules}} | ||
− | + | {{last_modified}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | == Description == | |
− | + | ||
− | + | This class acts like an union for common data types. A [[IC_Python_API:RLPy_RVariant|RVariant]] object holds a single value of a specified type T at a time. You can use [[#GetType ( self )|GetType]] to find out what type the variant holds, and get its value by one of the ToT() functions, e.g. [[#ToInt32 ( self, pSucess = None )|ToInt32]]. Currently, there are two types supported: float and int. | |
− | + | ||
− | + | == Member Functions == | |
− | + | ||
− | + | ||
− | == | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | === GetType ( self ) === | |
− | + | ||
− | + | Get type of this [[IC_Python_API:RLPy_RVariant|RVariant]] object. | |
− | ===GetType=== | + | |
− | + | ==== Returns ==== | |
− | + | :Type of this [[IC_Python_API:RLPy_RVariant|RVariant]] object - int | |
− | + | :*RLPy.RVariant.Float | |
− | Get | + | :*RLPy.RVariant.Int32 |
− | ====Returns==== | + | :*RLPy.RVariantUInt32 |
− | + | ||
− | + | <syntaxhighlight lang="python" line='line'> | |
− | + | x = RLPy.RVariant(-10) | |
− | + | print(x.GetType() == RLPy.RVariant.Int32) #true | |
− | <syntaxhighlight lang=" | + | |
− | RLPy.RVariant. | + | y = RLPy.RVariant(10.0) |
+ | print(y.GetType() == RLPy.RVariant.Float) #true | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | === ToFloat ( self, pSucess = None ) === | ||
+ | |||
Convert to float. | Convert to float. | ||
− | |||
− | |||
− | '''pSucess''' [IN] success or not - bool | + | See Also: [[#ToInt32 ( self, pSucess = None )|ToInt32]], [[#ToUInt32 ( self, pSucess = None )|ToUInt32]] |
− | + | ||
− | ====Returns==== | + | ==== Parameters ==== |
− | + | :'''pSucess''' [IN] success or not - bool | |
− | + | ||
− | + | ==== Returns ==== | |
− | + | :Value after conversion - float | |
− | <syntaxhighlight lang=" | + | |
− | RLPy.RVariant | + | <syntaxhighlight lang="python" line='line'> |
+ | x = RLPy.RVariant(-10) | ||
+ | f = x.ToFloat() | ||
+ | print(f) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | === ToInt32 ( self, pSucess = None ) === | ||
+ | |||
Convert to int32_t. | Convert to int32_t. | ||
− | |||
− | |||
− | '''pSucess''' [IN] success or not - bool | + | See Also: [[#ToFloat ( self, pSucess = None )|ToFloat]], [[#ToUInt32 ( self, pSucess = None )|ToUInt32]] |
− | + | ||
− | ====Returns==== | + | ==== Parameters ==== |
− | + | :'''pSucess''' [IN] success or not - bool | |
− | + | ||
− | + | ==== Returns ==== | |
− | + | :Signed integer value after conversion - int32 | |
− | <syntaxhighlight lang=" | + | |
− | RLPy.RVariant | + | <syntaxhighlight lang="python" line='line'> |
+ | f = RLPy.RVariant(-10.0) | ||
+ | x = f.ToInt32() | ||
+ | print(x) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | === ToUInt32 ( self, pSucess = None ) === | ||
+ | |||
Convert to uint32_t. | Convert to uint32_t. | ||
− | |||
− | |||
− | '''pSucess''' [IN] success or not - bool | + | See Also: [[#ToFloat ( self, pSucess = None )|ToFloat]], [[#ToInt32 ( self, pSucess = None )|ToInt32]] |
− | + | ||
− | ====Returns==== | + | ==== Parameters ==== |
− | + | :'''pSucess''' [IN] success or not - bool | |
− | </ | + | |
+ | ==== Returns ==== | ||
+ | :Unsigned integer value after conversion - uint32 | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | f = RLPy.RVariant(10.0) | ||
+ | x = f.ToUInt32() | ||
+ | print(x) | ||
+ | </syntaxhighlight> |
Latest revision as of 23:27, 13 April 2020
- Main article: Modules.
- Last modified: 04/13/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.
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
3
4 y = RLPy.RVariant(10.0)
5 print(y.GetType() == RLPy.RVariant.Float) #true
ToFloat ( self, pSucess = None )
Convert to float.
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.
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.
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)