Profile Picture

My second Python API trial

Posted By Delerna Last Year
You don't have permission to rate!
Author
Message
Delerna
Delerna
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 1.2K, Visits: 10.3K
In the process of moving back to my home town so cant spend the time on this that I want to yet.
Anyway, here is my second trial. I am sticking with keeping things simple because I want to get familiar enough with writing this stuff that I can be sure problems with the codes I write is not due to me not being familiar enough with it yet. So not trying to do anything serious for a while. Just experiment experiment to get it into my head.

Here is the result of the code I wrote.
https://forum.reallusion.com/uploads/images/44873954-70d9-412f-b88d-b79b.png

I have written a single main.py file that automatically loads into iClone when I start it.
This single file adds 3 groups to the plugins menu bar and I have added 3 links to each of those which just opens a message box.
The thing for me here is that I see a possibility of creating a single file with many options for use. Especially when they are all related to each other but perform slightly different things
Not sure exactly what I will do with it yet though. Just playing around with ideas that I may or may not use

Coming very shortly is the actual code with comments on what it does






i7-3770 3.4GHz CPU 16 GB Ram   
GeForce GTX1080 TI 11GB
Windows 10 Pro 64bit
Delerna
Delerna
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 1.2K, Visits: 10.3K
OK here is the code. I hace actually created this in a folder called 00MyFirstExperriment.
I intend to keep these simple and named 01------   02----- etc so I have something I can go back to remind me of things I might forget about





import RLPy             #This is creting a reference to iClones API engine which gives us abilities to controll what iClone does through python codes
import PySide2          #This converts a 3rd party application named QT into python library functions. QT creates classic and embedded graphical user interfaces into many applications using python.
                        #NOTE: QT (pronounsed cute) was automatically installed when you updated iClone to 7.4 or above.
from PySide2 import *   #??????? I think its importing everything in QT into this program but not sure whether my thought on that is correct yet
from PySide2.shiboken2 import wrapInstance  #wrapInstance is a reference to QT's method for adding things to other programs elements. In this case to iClones Plugins menu bar.
                                            #the way I see this is it just makes it a bit easier to reference it in the code.
                                            #Rather than typing       ic_dlg = PySide2.shiboken2.wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)
                                            # we can just type        ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)

def initialize_plugin():
    createAllTheAnimationOptions()      #I did it this way to make it easier to follow what the code is doing. Its my style.
    createAllThePropControlOptions()    #I did it this way to make it easier to follow what the code is doing. Its my style.
    createAllTheiCloneEventOptions()    #I did it this way to make it easier to follow what the code is doing. Its my style.   

   
   
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------   
def createAllTheAnimationOptions():   
    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)  #I tried making ic_dlg a global variable but it stopped working. Going to look into that later
    #First we check to see if AnimationFunctions already exists in iClones plugins menu bar and if it doesn't it gets added
    AnimationFunctions = ic_dlg.menuBar().findChild(QtWidgets.QMenu, "AnimationFunctions_menu")
    if (AnimationFunctions == None):
        AnimationFunctions = wrapInstance(int(RLPy.RUi.AddMenu("Animation Functions", RLPy.EMenu_Plugins)), QtWidgets.QMenu)
        AnimationFunctions.setObjectName("AnimationFunctions_menu")
       
    #Second we add the Animtion functions that users can click to achieve something. Probably should be a check to see if they exist also but not doing that yet
    AnimType1 = AnimationFunctions.addAction("Animation 1")     #Next we create links to appear within the AnimationFunctions
    AnimType1.triggered.connect(show_AnimType1)                 #And tell it what function to call when the user clicks it
   
    AnimType2 = AnimationFunctions.addAction("Animation 2")     #Next we create links to appear within the AnimationFunctions
    AnimType2.triggered.connect(show_AnimType2)                 #And tell it what function to call when the user clicks it
   
    AnimType3 = AnimationFunctions.addAction("Animation 3")     #Next we create links to appear within the AnimationFunctions
    AnimType3.triggered.connect(show_AnimType3)                 #And tell it what function to call when the user clicks it     
   
#Here are the functions that will get called when the user clicks one of the animation links added to iclones plugins menu bar   
def show_AnimType1():
    RLPy.RUi.ShowMessageBox("AnimType1", "Need to figure out what AnimType1 is going to do", RLPy.EMsgButton_Ok)   
   
def show_AnimType2():
    RLPy.RUi.ShowMessageBox("AnimType2", "Need to figure out what AnimType2 is going to do", RLPy.EMsgButton_Ok)       
   
def show_AnimType3():
    RLPy.RUi.ShowMessageBox("AnimType3", "Need to figure out what AnimType3 is going to do", RLPy.EMsgButton_Ok)       
      
   
   
   
   
   
   
#Not commenting the rest of these because they are really similar to what is done with the Animation Options   
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------       
def createAllThePropControlOptions():
    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)
    PopControlFunctions = ic_dlg.menuBar().findChild(QtWidgets.QMenu, "PopControlFunctions_menu")
    if (PopControlFunctions == None):
        PopControlFunctions = wrapInstance(int(RLPy.RUi.AddMenu("Pop Functions", RLPy.EMenu_Plugins)), QtWidgets.QMenu)
        PopControlFunctions.setObjectName("PopControlFunctions_menu")
       
    PopType1 = PopControlFunctions.addAction("Pop Control 1")
    PopType1.triggered.connect(show_PopType1)       
       
    PopType2 = PopControlFunctions.addAction("Pop Control 2")
    PopType2.triggered.connect(show_PopType2)         
 
    PopType3 = PopControlFunctions.addAction("Pop Control 3")
    PopType3.triggered.connect(show_PopType3)         
 
def show_PopType1():
    RLPy.RUi.ShowMessageBox("PopType1", "Need to figure out what PopControl1 is going to do", RLPy.EMsgButton_Ok)
   
def show_PopType2():
    RLPy.RUi.ShowMessageBox("PopType2", "Need to figure out what PopControl2 is going to do", RLPy.EMsgButton_Ok)   
   
def show_PopType3():
    RLPy.RUi.ShowMessageBox("PopType3", "Need to figure out what PopControl3 is going to do", RLPy.EMsgButton_Ok)         
   
 

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------    
def createAllTheiCloneEventOptions():      
    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow) 
    EventOptionFunctions = ic_dlg.menuBar().findChild(QtWidgets.QMenu, "EventOptionFunctions_menu")
    if (EventOptionFunctions == None):
        EventOptionFunctions = wrapInstance(int(RLPy.RUi.AddMenu("Event Functions", RLPy.EMenu_Plugins)), QtWidgets.QMenu)
        EventOptionFunctions.setObjectName("EventOptionFunctions_menu")
       
    EventOption1 = EventOptionFunctions.addAction("Event Option 1")
    EventOption1.triggered.connect(show_EventOption1)       
       
    EventOption2 = EventOptionFunctions.addAction("Event Option 2")
    EventOption2.triggered.connect(show_EventOption2)         
 
    EventOption3 = EventOptionFunctions.addAction("Event Option 3")
    EventOption3.triggered.connect(show_EventOption3)       
def show_EventOption1():
    RLPy.RUi.ShowMessageBox("EventOption1", "Need to figure out what EventOption1 is going to do", RLPy.EMsgButton_Ok)
   
def show_EventOption2():
    RLPy.RUi.ShowMessageBox("EventOption2", "Need to figure out what EventOption2 is going to do", RLPy.EMsgButton_Ok)   
   
def show_EventOption3():
    RLPy.RUi.ShowMessageBox("EventOption3", "Need to figure out what EventOption3 is going to do", RLPy.EMsgButton_Ok)      



i7-3770 3.4GHz CPU 16 GB Ram   
GeForce GTX1080 TI 11GB
Windows 10 Pro 64bit
Edited
Last Year by Delerna
Kelleytoons
Kelleytoons
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (15.4K reputation)Distinguished Member (15.4K reputation)Distinguished Member (15.4K reputation)Distinguished Member (15.4K reputation)Distinguished Member (15.4K reputation)Distinguished Member (15.4K reputation)Distinguished Member (15.4K reputation)Distinguished Member (15.4K reputation)Distinguished Member (15.4K reputation)

Group: Forum Members
Last Active: 4 hours ago
Posts: 5.3K, Visits: 10.2K
It's good you are exploring this, as I'm sure a lot of folks will want to go this route.

(I'm approaching from the opposite directly, coding iClone manipulation stuff.  But I keep getting stuck by the bugs so will have to wait until the first of the year when they are fixed).



Alienware Aurora R7, Win 10, i7-8700k, 4.7GHz CPU, 32GB RAM, GTX Titan XP (12GB), Samsung 960 Pro 2TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
Delerna
Delerna
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 1.2K, Visits: 10.3K
Thanks Kellytoons.
Yes part of why Im doing it this way Is I will get familiar enough with this language and by the time all bugs are fixed I will be ready to start doing serious things


i7-3770 3.4GHz CPU 16 GB Ram   
GeForce GTX1080 TI 11GB
Windows 10 Pro 64bit



Reading This Topic