Difference between revisions of "IC Python API:RLPy RIBase"

From Reallusion Wiki!
Jump to: navigation, search
(Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}}== Detailed Description == This class is the base class of components in the scene. The class provides a method to de...")
 
m
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}== Detailed Description ==
+
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
This class is the base class of components in the scene.
+
{{last_modified}}
The class provides a method to determine the component is available or not.
+
 
==Member Functions==
+
== Description ==
===IsValid===
+
 
<syntaxhighlight lang="Python">
+
This is the base class for all scene objects such as [[IC_Python_API:RLPy_RIAvatar|RIAvatar]], [[IC_Python_API:RLPy_RIProp|RIProp]], [[IC_Python_API:RLPy_RICamera|RICamera]], etc.  Deployed objects might come across some points of operation failure during the course of one's work with the scene, i.e. deletion, undo/redo operations, file importation, etc.  Therefore, [[IC_Python_API:RLPy_RIBase|RIBase]] provides [[#IsValid ( self )|IsValid]] to detect for scene objects' validity.
RLPy.RIBase.IsValid ( self )
+
 
 +
== Inheritance ==
 +
 
 +
[[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RIClip|RIClip]] | [[IC_Python_API:RLPy_RIMaterialComponent|RIMaterialComponent]] | [[IC_Python_API:RLPy_RIMaterialComponent|RIMaterialComponent]] | [[IC_Python_API:RLPy_RINode|RINode]] | [[IC_Python_API:RLPy_RISkeletonComponent|RISkeletonComponent]] | [[IC_Python_API:RLPy_RIVisemeComponent|RIVisemeComponent]]
 +
[[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RIObject|RIObject]] > [[IC_Python_API:RLPy_RIAvatar|RIAvatar]] | [[IC_Python_API:RLPy_RICamera|RICamera]] | [[IC_Python_API:RLPy_RIParticle|RIParticle]] | [[IC_Python_API:RLPy_RIProp|RIProp]]
 +
[[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RIObject|RIObject]] > [[IC_Python_API:RLPy_RILight|RILight]] > [[IC_Python_API:RLPy_RIDirectionalLight|RIDirectionalLight]] | [[IC_Python_API:RLPy_RIPointLight|RIPointLight]] | [[IC_Python_API:RLPy_RISpotLight|RISpotLight]]
 +
 
 +
== Member Functions ==
 +
 
 +
=== IsValid ( self ) ===
 +
 
 +
Check whether or not the scene object exists; If detection fails, return '''False'''.
 +
 
 +
==== Returns ====
 +
:'''True''' if valid, else '''False''' - bool
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
avatar = None
 +
event_callback = None
 +
 
 +
class REventCallbackSampleCode(RLPy.REventCallback):
 +
    def __init__(self):
 +
        RLPy.REventCallback.__init__(self)
 +
    def OnObjectDeleted(self):
 +
        global avatar
 +
        if not avatar.IsValid():
 +
            print ("The avatar has been deleted")
 +
 
 +
def run_script():
 +
    global avatar
 +
    global event_callback
 +
    avatar_list = RLPy.RScene.GetAvatars()
 +
    avatar = avatar_list[0]
 +
    event_callback = REventCallbackSampleCode()
 +
    id = RLPy.REventHandler.RegisterCallback(event_callback)
 
</syntaxhighlight>
 
</syntaxhighlight>
Is valid or not.
 
====Returns====
 
<div style="margin-left: 2em;">Valid or not - bool
 
</div>
 

Latest revision as of 23:40, 14 April 2020

Main article: Modules. Last modified: 04/14/2020

Description

This is the base class for all scene objects such as RIAvatar, RIProp, RICamera, etc. Deployed objects might come across some points of operation failure during the course of one's work with the scene, i.e. deletion, undo/redo operations, file importation, etc. Therefore, RIBase provides IsValid to detect for scene objects' validity.

Inheritance

RIBase > RIClip | RIMaterialComponent | RIMaterialComponent | RINode | RISkeletonComponent | RIVisemeComponent 
RIBase > RIObject > RIAvatar | RICamera | RIParticle | RIProp 
RIBase > RIObject > RILight > RIDirectionalLight | RIPointLight | RISpotLight 

Member Functions

IsValid ( self )

Check whether or not the scene object exists; If detection fails, return False.

Returns

True if valid, else False - bool
 1 avatar = None
 2 event_callback = None
 3 
 4 class REventCallbackSampleCode(RLPy.REventCallback):
 5     def __init__(self):
 6         RLPy.REventCallback.__init__(self)
 7     def OnObjectDeleted(self):
 8         global avatar
 9         if not avatar.IsValid():
10             print ("The avatar has been deleted")
11 
12 def run_script():
13     global avatar
14     global event_callback
15     avatar_list = RLPy.RScene.GetAvatars()
16     avatar = avatar_list[0] 
17     event_callback = REventCallbackSampleCode()
18     id = RLPy.REventHandler.RegisterCallback(event_callback)