Profile Picture

Turning Props On - Off script

Posted By videodv 5 Years Ago
You don't have permission to rate!
Author
Message
videodv
videodv
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
Hi
Tinkering around I thought the following script might be usefull to some.
The script will allow you to turn props on or off on the timeline.
How to use:
load a scene then run the script you will see a treeview with all your props displayed set the timeline to a position you wish to turn the prop off then tick the checkbox and select you prop from the list it will turn off, move the timeline then untick the checkbox and select the same prop from the list it will now turn on.

The following is the script just copy and paste in Note Pad or simular and save it as somename.py

import PySide2, RLPy
from PySide2 import *
from PySide2.QtWidgets import *
from PySide2.shiboken2 import wrapInstance

#-- Make a global variable contain dialog --#
invisable_dialog = None

class SetScreenWidget(QtWidgets.QWidget):
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
 
        tree_view = QtWidgets.QTreeWidget()
        tree_view.setMinimumSize(270, 600)
        self.check_box = QtWidgets.QCheckBox("Toggle to make visable\invisable")
       
        get_screen_objects(tree_view)
       
        tree_view.itemClicked.connect(self.run_tree_view)       
        layout = QtWidgets.QHBoxLayout()
        layout.addWidget(tree_view)
        layout.addWidget(self.check_box)   
        self.setLayout(layout)
       
    def run_tree_view(self, it, col):
           
        RLPy.RGlobal.GetTime()
        time_line = RLPy.RGlobal_GetTime()
           
        prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, it.text(col))        
 
        if self.check_box.isChecked():
            if prop:
                prop.SetVisible(RLPy.RTime(time_line), False)
        else:             
            if prop:
                prop.SetVisible(RLPy.RTime(time_line), True)
              
def run_script():
    global invisable_dialog

    set_screen_widget = SetScreenWidget()
  
    invisable_dialog = RLPy.RUi.CreateRDialog()
    invisable_dialog.SetWindowTitle("Make Invisable")
   
    #-- Create Pyside layout for RDialog --#
    pyside_dialog = wrapInstance(int(invisable_dialog.GetWindow()), QtWidgets.QDialog)
    sample_layout = pyside_dialog.layout()
   
    #-- Assign the setscreenwidget class to PySide Dialog --#
    sample_layout.addWidget(set_screen_widget)
   
    invisable_dialog.Show()

def get_screen_objects(tree_view):
    #-----Get all props -----
    prop_objects = RLPy.RScene.FindObjects( RLPy.EObjectType_Prop )

    tree_view.setColumnCount(1)
    tree_view.setHeaderLabels(['Scene Objects'])

    #Prop level item and all props
    item0 = QTreeWidgetItem(tree_view, ['Prop'])
    #-----Create item for all scene objects-----
    for item in prop_objects:
        _name = item.GetName()
        QTreeWidgetItem(item0, [_name])

Chris.



Reading This Topic