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

From Reallusion Wiki!
Jump to: navigation, search
m
m
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Detailed Description==
+
{{last_modified}}
This class is the base class of components in the scene.
+
 
The class provides a method to determine the component is available or not.
+
== Description ==
==Member Functions==
+
 
===IsValid===
+
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, e.g. deletion, undo/redo operations, file importation, etc.  Therefore, '''RIBase''' provides '''IsValid()''' to detect for scene objects' validity.
 +
 
 +
== Member Functions ==
 +
 
 +
=== IsValid ( self ) ===
 +
 
 +
Check whether or not the scene object exists; If detection fails, return '''False'''.  Call '''IsValid()''' to determine the validity of the object or use an EventCallback to update the state of the object after an event is triggered.
 +
 
 +
==== Returns ====
 +
:Valid or not - bool
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RIBase.IsValid ( self )
+
import RLPy
 +
 
 +
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>
 
==Inherited By==
 
This class is inherited by the following classes:
 
{| class="wikitable"
 
!Class
 
!Description
 
|-
 
| [[ IC_Python_API:RLPy_RIClip | Clip ]] || Used to access the clip data of the animation.
 
|-
 
| [[ IC_Python_API:RLPy_RIFaceComponent | FaceComponent ]] || The interface to the face key in the avatar.
 
|-
 
| [[ IC_Python_API:RLPy_RIHikEffectorComponent | HikEffectorComponent ]] || The interface to the human IK effector in the avatar.
 
|-
 
| [[ IC_Python_API:RLPy_RIMaterialComponent | MaterialComponent ]] || RIMaterialComponent.
 
|-
 
| [[ IC_Python_API:RLPy_RIMorphComponent | MorphComponent ]] || RIMorphComponent.
 
|-
 
| [[ IC_Python_API:RLPy_RINode | Node ]] || The interface to nodes in the scene.
 
|-
 
| [[ IC_Python_API:RLPy_RIObject | Object ]] || The base class of the objects in the scene.
 
|-
 
| [[ IC_Python_API:RLPy_RISkeletonComponent | SkeletonComponent ]] || The interface to the bone system in the scene.
 
|-
 
| [[ IC_Python_API:RLPy_RIVisemeComponent | VisemeComponent ]] || RIVisemeComponent.
 
|-
 
| [[ IC_Python_API:RLPy_RIAvatar | Avatar ]] || The interface to avatars in the scene.
 
|-
 
| [[ IC_Python_API:RLPy_RICamera | Camera ]] || The interface to cameras in the scene.
 
|-
 
| [[ IC_Python_API:RLPy_RILight | Light ]] || The interface to lights in the scene.
 
|-
 
| [[ IC_Python_API:RLPy_RIParticle | Particle ]] || ( Experimental Class ) the interface to particles in the scene.
 
|-
 
| [[ IC_Python_API:RLPy_RIProp | Prop ]] || The interface to props in the scene.
 
|-
 
| [[ IC_Python_API:RLPy_RIDirectionalLight | DirectionalLight ]] || The interface to directional light in the scene.
 
|-
 
| [[ IC_Python_API:RLPy_RIPointLight | PointLight ]] || The interface to point light in the scene.
 
|-
 
| [[ IC_Python_API:RLPy_RISpotLight | SpotLight ]] || The interface to spot light in the scene.
 
|}
 

Revision as of 19:30, 29 March 2020

Main article: Modules.
Last modified: 03/29/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, e.g. deletion, undo/redo operations, file importation, etc. Therefore, RIBase provides IsValid() to detect for scene objects' validity.

Member Functions

IsValid ( self )

Check whether or not the scene object exists; If detection fails, return False. Call IsValid() to determine the validity of the object or use an EventCallback to update the state of the object after an event is triggered.

Returns

Valid or not - bool
import RLPy

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)