Difference between revisions of "IC Python API:RLPy RIBase"
From Reallusion Wiki!
Chuck (RL) (Talk | contribs) m |
Chuck (RL) (Talk | contribs) m |
||
Line 1: | Line 1: | ||
{{TOC}} | {{TOC}} | ||
{{Parent|IC_Python_API:RL_Python_Modules|Modules}} | {{Parent|IC_Python_API:RL_Python_Modules|Modules}} | ||
− | == | + | {{last_modified}} |
− | This | + | |
− | + | == 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. | + | 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> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 18: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)