Difference between revisions of "IC Python API:List All Props"

From Reallusion Wiki!
Jump to: navigation, search
m
m (Necessary Modules)
Line 25: Line 25:
  
 
The Shiboken module can be used to access internal information related to Pyside's binding technology.  Access to this internal information is required to integrate Pyside with Qt based programs that offer Python scripting like iClone or just for debug purposes.
 
The Shiboken module can be used to access internal information related to Pyside's binding technology.  Access to this internal information is required to integrate Pyside with Qt based programs that offer Python scripting like iClone or just for debug purposes.
 +
 +
== Building the UI ==
 +
 +
Creating a window requires that we define it as a global entity and reference it in '''run_script''' definition.
 +
 +
<syntaxhighlight lang="Python">
 +
# User Interface
 +
dockable_window = None
 +
 +
def run_script():
 +
    global dockable_window
 +
 +
    # Create an iClone Dock Widget
 +
    dockable_window = RLPy.RUi.CreateRDockWidget()
 +
    dockable_window.SetWindowTitle("All Scene Props")
 +
    dock = wrapInstance(int(dockable_window.GetWindow()),
 +
                        QtWidgets.QDockWidget)
 +
    main_widget = QtWidgets.QWidget()
 +
    dock.setWidget(main_widget)
 +
 +
    main_widget_layout = QtWidgets.QVBoxLayout()
 +
    main_widget.setLayout(main_widget_layout)
 +
 +
    combo_box = QtWidgets.QComboBox()
 +
 +
    main_widget_layout.addWidget(combo_box)
 +
 +
    dockable_window.Show()
 +
</syntaxhighlight>
 +
 +
== Populating the Prop List ==

Revision as of 22:44, 21 April 2019

Main article: RL Python Samples.

This article will focus on creating a drop down list for all of the existing props in the current iClone scene.

Necessary Modules

Get started by loading the required modules for the script.

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

We'll need RLPy to access iClone's Python API and Pyside2 related modules to create a functional interface.

Qt Widgets

The Qt Widgets module extends Qt GUI with C++ widget functionality. This is the building blocks for composing the user interface.

Shiboken

The Shiboken module can be used to access internal information related to Pyside's binding technology. Access to this internal information is required to integrate Pyside with Qt based programs that offer Python scripting like iClone or just for debug purposes.

Building the UI

Creating a window requires that we define it as a global entity and reference it in run_script definition.

# User Interface
dockable_window = None

def run_script():
    global dockable_window

    # Create an iClone Dock Widget
    dockable_window = RLPy.RUi.CreateRDockWidget()
    dockable_window.SetWindowTitle("All Scene Props")
    dock = wrapInstance(int(dockable_window.GetWindow()),
                        QtWidgets.QDockWidget)
    main_widget = QtWidgets.QWidget()
    dock.setWidget(main_widget)

    main_widget_layout = QtWidgets.QVBoxLayout()
    main_widget.setLayout(main_widget_layout)

    combo_box = QtWidgets.QComboBox()

    main_widget_layout.addWidget(combo_box)

    dockable_window.Show()

Populating the Prop List