Profile Picture

Can someone code a Python shaky-cam script?

Posted By gordryd 7 Years Ago
Rated 5 stars based on 1 vote.
1
2
3

Author
Message
videodv
videodv
Posted 7 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 342, Visits: 12.0K
Just a quick update here is the code to populate a combo box

ui_combo_box = qtui_widget.findChild(PySide2.QtWidgets.QComboBox, "comboBox")

get_screen_objects_combo_box(ui_combo_box)

def get_screen_objects_combo_box():
    #-----Get all props -----
    prop_objects = RLPy.RScene.FindObjects( RLPy.EObjectType_Prop )      
    for item in prop_objects:
        ui_combo_box.addItem(item.GetName())

And to get the selected item
ui_combo_box.activated[str].connect(run_combo_box)

def run_combo_box(text):
    print("Combo Box Text: {}".format(text.GetName())

Hope this helps
Chris.


gordryd
gordryd
Posted 7 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)

Group: Forum Members
Last Active: Last Month
Posts: 730, Visits: 8.1K
Thanks Chris - actually, I forgot to mention something that makes it even more complicated. -- I would like to populate (change) all the other boxes depending on which 'Preset' is selected.  As they say at work, continuous process improvement...

Reallusion Certified Director / Reallusion Best Visual Award / Reallusion Certified Content Developer
See all the G-Tools Plug-Ins available for iClone here: G-Tools Plug-Ins


videodv
videodv
Posted 7 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 342, Visits: 12.0K
gordryd (4/22/2019)
@Chris - looks like you know what you are doing (as opposed to me just cobbling together pieces that others have contributed).  So I created a form in QT Designer, but have questions about a few things.  Here is what the form looks like in QTD:
https://forum.reallusion.com/uploads/images/e8e50f3b-06c4-468d-ba8c-dbfe.jpg
How would I do the following?
1) Populate the Preset ComboBox from a list inside my main.py script when the form opens
2) Populate the Object ComboBox from current iClone project (with either all Cameras or all Props - Camera/Prop selection will be made before box is displayed) when the form opens
3) Pass values from SpinBoxes to main.py variables when 'OK' is clicked?
Thanks - when I get this to a stage that I am satisfied with I will make it available to all that want it.



Hi gordryd

Not sure if I would say I know what I am doing as yourself I have had a lot of experimenting and head scratching over the last couple of months but I seem to have got the basic jist at least, anyway to answer you questions see the code below.


1. Not sure how to do this as yet (see below) but You can set the options for the Combobox from within the QT Designer just right click and select "edit Items"

2. Object Combo Box

I use this function to populate a TreeWidget with all the relevant objects I wish from the scene
not sure how to set a combo box but it should be simular.

Im not at my home computer at the moment so cannot check this out but i will check this out tomorrow when I finish work and at home.
Perhaps someone with more knowlege with Combo Boxes could chime in here and put both of us right?

def get_scene_objects(ui_treeWidget):
    #-----Get all avatar / prop / camera / light-----
    avatar_objects = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar ) # Get all avatars in scene
    prop_objects = RLPy.RScene.FindObjects( RLPy.EObjectType_Prop ) # Get All Props in Scene
    light_objects = RLPy.RScene.FindObjects( RLPy.EObjectType_Light ) # Get All Lights in Scene
    camera_objects = RLPy.RScene.FindObjects( RLPy.EObjectType_Camera ) # Get A Cameras in scene

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

    #Avatar level item and its kids
    item0 = QTreeWidgetItem(ui_treeWidget, ['Avatar'])
    #-----Create item for all scene objects-----
    for item in avatar_objects:
        _name = item.GetName()
        QTreeWidgetItem(item0, [_name])
    #Prop level item and its kids
    item0 = QTreeWidgetItem(ui_treeWidget, ['Prop'])
    #-----Create item for all scene objects-----
    for item in prop_objects:
        _name = item.GetName()
        QTreeWidgetItem(item0, [_name])
    #Light level item and its kids
    item0 = QTreeWidgetItem(ui_treeWidget, ['Light'])
    #-----Create item for all scene objects-----
    for item in light_objects:
        _name = item.GetName()
        QTreeWidgetItem(item0, [_name])
    #Camera level item and its kids
    item0 = QTreeWidgetItem(ui_treeWidget, ['camera'])
    #-----Create item for all scene objects-----
    for item in camera_objects:
        _name = item.GetName()
        QTreeWidgetItem(item0, [_name])

ui_tree_view = qtui_widget.findChild(PySide2.QtWidgets.QTreeWidget, "treeWidget") # Find the tree widget

ui_tree_view.itemClicked.connect(run_tree_view) # Go and do something


def run_tree_view(it, col):
    print(it.text(col)) # Print the tree widget value selected



3. Spin Boxes

some_spin_box_value = 0 # This is global for the spinbox value place under your imports at top of script

    ui_spin_box = qtui_widget.findChild(PySide2.QtWidgets.QSpinBox, "spinBox") # Find the control Spin Box with name "spinBox" or your own name

    ui_spin_box.valueChanged.connect(run_spin_box) # Run when spinbox updated

def run_spin_box(value):
    Global some_spin_box_value
    some_spin_box_value = value # Save the spinbox value to use later in the script

Hope this helps in some way.
Chris.


gordryd
gordryd
Posted 7 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)

Group: Forum Members
Last Active: Last Month
Posts: 730, Visits: 8.1K
@Chris - looks like you know what you are doing (as opposed to me just cobbling together pieces that others have contributed).  So I created a form in QT Designer, but have questions about a few things.  Here is what the form looks like in QTD:
https://forum.reallusion.com/uploads/images/e8e50f3b-06c4-468d-ba8c-dbfe.jpg
How would I do the following?
1) Populate the Preset ComboBox from a list inside my main.py script when the form opens
2) Populate the Object ComboBox from current iClone project (with either all Cameras or all Props - Camera/Prop selection will be made before box is displayed) when the form opens
3) Pass values from SpinBoxes to main.py variables when 'OK' is clicked?
Thanks - when I get this to a stage that I am satisfied with I will make it available to all that want it.



Reallusion Certified Director / Reallusion Best Visual Award / Reallusion Certified Content Developer
See all the G-Tools Plug-Ins available for iClone here: G-Tools Plug-Ins


videodv
videodv
Posted 7 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 342, Visits: 12.0K
4u2ges (4/21/2019)
@ Delerna Thank you and good luck!

@Chris Awesome! Thank you for the links and a demo. Will get to the bottom of it at some point.


Your welcome
Chris.

4u2ges
4u2ges
Posted 7 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)

Group: Forum Members
Last Active: 2 days ago
Posts: 5.3K, Visits: 16.8K
@ Delerna Thank you and good luck!

@Chris Awesome! Thank you for the links and a demo. Will get to the bottom of it at some point.




videodv
videodv
Posted 7 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 342, Visits: 12.0K
Delerna (4/21/2019)
4u2ges/ videodv. 
More good efforts. I started working on this while still living in Sydney before I moved back to my home town. Had so many things to do since I moved I got lost on working with python plugin.
Going to get back into it this though and I will be using your codes and the many that have been posted to assist me to get a good understanding of coding iClone.


Hi
Took me a while to get my head around QT and Python as well as the Iclone API but Im getting there now.
Wish you all the best as I learned a lot from the scripts put up by others and of course a lot of head scratching :) and experimenting :ermm:

Chris.




videodv
videodv
Posted 7 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 342, Visits: 12.0K
Data Juggler (4/21/2019)
@Chris Many thanks! As soon as I get a chance I will see what I can do with this.



Your welcome

Chris.
Delerna
Delerna
Posted 7 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (8.5K reputation)Distinguished Member (8.5K reputation)Distinguished Member (8.5K reputation)Distinguished Member (8.5K reputation)Distinguished Member (8.5K reputation)Distinguished Member (8.5K reputation)Distinguished Member (8.5K reputation)Distinguished Member (8.5K reputation)Distinguished Member (8.5K reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 1.5K, Visits: 14.8K
4u2ges/ videodv. 
More good efforts. I started working on this while still living in Sydney before I moved back to my home town. Had so many things to do since I moved I got lost on working with python plugin.
Going to get back into it this though and I will be using your codes and the many that have been posted to assist me to get a good understanding of coding iClone.


i7-3770 3.4GHz CPU 16 GB Ram   
GeForce GTX1080 TI 11GB
Windows 10 Pro 64bit
videodv
videodv
Posted 7 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)Distinguished Member (2.9K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 342, Visits: 12.0K
I forgot to say when you open the designer select create dialog without buttons and also make sure you set the min and max size of your dialog or you only see a title bar when running the script.

Chris.

1
2
3



Reading This Topic