Profile Picture

iClone 7.5 (with new Python APIs ) is Available!

Posted By luke (RL) 6 Years Ago
Rated 5 stars based on 1 vote.
Author
Message
luke (RL)
luke (RL)
Posted 6 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)

Group: Power Developer
Last Active: Last Month
Posts: 289, Visits: 5.6K
Dear Developers,

I'm Luke from Reallusion. I'm in charge of this Python project since the end of last year. 
It's not easy to have the scripting ability in iClone, so even we knew there are so many API not available in the first version, we still insist to release to the public and hope to learn from your requests and needs to help us to enhance that.
Except for the API itself, we also understand that good document will help you to get into the swing of it, so this thread we want to gather all your samples request and our team will do it then upload to the GitHub for your reference. So please don't hesitate to offer your request here. 
Please note that in the first run, our team only can support the simple sample requests, such as how to get all the keys from the prop or how to get the selected object, etc.
Let's do this! We hope this Python API can extend the ability of iClone and you folks can do various plugins to make a difference of iClone. thanks

last thread update (https://forum.reallusion.com/FindPost403996.aspx)

==================== Sample Request ====================
Kelley - How to get all the keys from Prop. (uploaded 181227)
Kelley - How to get the object selected. (uploaded 181227)
Kelley - How to get the parent object is my other main request. ( 0.7.1 ) 
Kelley - How to delete key. (uploaded 181228)
RobertoColombo - How to get mesh data. ( we can't do it now, update to our API roadmap ) 
RobertoColombo - Just to give an example: ShowMessageBox(), and the detailed description of parameters. (uploaded 181228)
videodv - How to change the Transition Curve of a material. ( 0.7.1 ) 
dogged2003 - How to get the bones of a non-human avatar? And manage them? ( we can't do it now, update to our API roadmap ) 
jlittle - Need example of AddUVData where one adds an image file (i.e. jpg) to one of the texture channels.
jlittle - How to determine a materials shader type (PBR or Traditional). ( we can't do it now, update to our API roadmap ) 
jlittle - How to get/set material transition keys. ( 0.7.1 ) 
The-any-Key - Some examples to get and set the rotation quaternions for objects in the local and world (or a way to transform the world to local and set it or vice versa).

============ New Patch Released - iClone 7.5 (7/25/2019) ============

Please check out the Release Note to know more about new Python APIs.


============ New Patch Released - 0.7.4 (7/5/2019) ============

Download Link
 ( iClone Developer Edition )
Add:
  • Viseme related API.
  • HIK Effector related API.
Fix:
  • Retrieved prop quaternion not converting to degrees.

============ New Patch Released - 0.7.2 (2/27/2019) ============

Download Link ( iClone Developer Edition )
This version only for Python Development that contains functions that may not behave properly. There are potential risks to using this software beyond its intended purposes. By continuing to use this software, you are fully aware of the potential risks and agree to take responsibility.

Add APIs:
1. Edit & Delete the viseme key
2. Create viseme clip from audio file
3. Clone objects
4. Load file will return the object handle (LoadObject)
5. Set or cancel dummy option (SetDummy, IsDummy)

============ Previous Patch Released - 0.7.1 (2/1/2019) ============
Add APIs:
1. Add Viseme ( Edit & Delete will be in next patch )
2. Load texture file to material channel
3. Attach and Link
4. Direct control Face key
5. Beable to set transition curve of material
6. Set object name
7. Get bounding box information from object
8. Set pivot
Fix:
1. GetMeshNames() will return wrong name, so the GetMaterialNames() will failed.

Edited
5 Years Ago by Tony (RL)
Kelleytoons
Kelleytoons
Posted 6 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (37.8K reputation)Distinguished Member (37.8K reputation)Distinguished Member (37.8K reputation)Distinguished Member (37.8K reputation)Distinguished Member (37.8K reputation)Distinguished Member (37.8K reputation)Distinguished Member (37.8K reputation)Distinguished Member (37.8K reputation)Distinguished Member (37.8K reputation)

Group: Forum Members
Last Active: 2 Months Ago
Posts: 9.2K, Visits: 22.1K
How to get the parent object is my other main request.



Alienware Aurora R16, Win 11, i9-149000KF, 3.20GHz CPU, 64GB RAM, RTX 4090 (24GB), Samsung 870 Pro 8TB, Gen3 MVNe M-2 SSD, 4TBx2, 39" Alienware Widescreen Monitor
Mike "ex-genius" Kelley
RobertoColombo
RobertoColombo
Posted 6 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 1.6K, Visits: 3.0K
Hi,

one thing that would be extremely useful is the possibility to access the mesh data for the various assets (props, terrain, etc.), i.e. vertex coordinates.
For example, if we develop some tools to move an asset, eventually should be possible to avoid intersections with teh terrain or other objects.

In addition, I wish you can have a look at the thread here: https://forum.reallusion.com/399142/Python-FAQ-Tracker
There are several quetsions pointing to gaps and things not clear in the documentation.

Thanks
Regards

  Roberto

My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO + 1x2TB Samsung
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the MOTU M4 I/F) / DirectX: 12

RobertoColombo
RobertoColombo
Posted 6 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 1.6K, Visits: 3.0K
Hi,

I am not sure how to start the main,py script when iClone is launched.
1. I created a new folder named "OpenPlugin" under Bin64
2. I created main.py in OpenPlugin folder and copy-pasted the code provided in the doc.
3. Started iClone... nothing happens...

Any idea about what could be wrong ?

  Roberto

My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO + 1x2TB Samsung
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the MOTU M4 I/F) / DirectX: 12

RobertoColombo
RobertoColombo
Posted 6 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 1.6K, Visits: 3.0K

Documentation for RUi is largely incomplete.
Just to give an example (but the following is valid for every method): ShowMessageBox()

a. There is no indication aboutwhat is the value type of the input parameters.
      Intuitively the first two are strings but what about the olthers ?
      The "Hello world" Python example uses the value "RLPy.EMsgButton_Ok" => how to link from the doc of this function that this is the value to be used ?
b. The "Hello world" Python example uses 3 input parameters, whereas in teh doc there are listred 5.
       Which one are optional ?
c. Retun is "button status". 
      What does this mean ?
      What are the possible values ?


My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO + 1x2TB Samsung
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the MOTU M4 I/F) / DirectX: 12

RobertoColombo
RobertoColombo
Posted 6 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 1.6K, Visits: 3.0K
The "main" problem I have right now is exactly... how to run the "main.py" script at the startup.
I created a new folder under Bin64, named OpenPlugin
Put 'main.py' in there, with teh code provided in the doc.

Nothing happens...

So, I changed the function name to run_script() and manually loaded it.
The script generates this error in the console window: 
   <class 'AttributeError'>, File: E:/WorkingArea/iClone/Python/Main.py, Line: 7

corresponding to the code:

   ic_dlg = PySide2.shiboken2.wrapInstance(int(RLPy.RUi.GetMainWindow()), PySide2.QtWidgets.QMainWindow)


My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO + 1x2TB Samsung
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the MOTU M4 I/F) / DirectX: 12

Edited
6 Years Ago by RobertoColombo
RobertoColombo
RobertoColombo
Posted 6 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 1.6K, Visits: 3.0K


I have another issue that i can't get through.
What I want to do is a very simple task: to be able to calla function defined ina certain file from another file.

So, I created a file with a function that print a simple message.
Then, i created another file, with an import statement for the 1st file and a call to that function within run_script().
I am sure that teh file with the function is imported because if i insert some errors there they are displayed during the "import" phase.
Problem is that when I run this script, i get the error "<class 'NameError'>" exactly at the line of code where I call the function defined in the other file.
It looks like iClone can't find this file and the function within it.
The two files are placed in the same directory.

Pls, let us know how to do this, because this is the basis to split the code into different modules

My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO + 1x2TB Samsung
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the MOTU M4 I/F) / DirectX: 12

RobertoColombo
RobertoColombo
Posted 6 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 1.6K, Visits: 3.0K
Thanks to "waveact" offline help, the way to run main.py at the start of iClone is now solved!

The way to do that is to have a TWO level folder under Bin64, i.e.: Bin64\OpenPlugin\[here you need to create another folder with any name you want]
In my case I created \OpenPlugin\PythonAPI
Then, within PythonAPI, put the main.py file.

When iClone starts, I can see that it is scanning the available plug ins and at the end also PythonAPI is displayed.
Then the main.py is executed.... but here I still have the problem of this line of code, reported above:
 
   ic_dlg = PySide2.shiboken2.wrapInstance(int(RLPy.RUi.GetMainWindow()), PySide2.QtWidgets.QMainWindow)

so, what I did so far is to have a main.py with just one print() inside the initialize_plugin() function, i.e.

import RLPy

def initialize_plugin():
    print("Ciao")

when iClone starts, I can see "Ciao" displayed in the Python console.

Now that iClone can recognize the main.py script at teh start-up, I tried to insert in it a call to a function placed into another script, saved in the same \OpenPlugin\PythonAPI directory.
Even in this can nothing happens, so I still have no idea how to split the code among different files...

My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO + 1x2TB Samsung
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the MOTU M4 I/F) / DirectX: 12

Edited
6 Years Ago by RobertoColombo
RobertoColombo
RobertoColombo
Posted 6 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)Distinguished Member (10.8K reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 1.6K, Visits: 3.0K
main.py issue is now solved.

Two more lines of codes are needed, otherwise iClone is not able to see the elements within PySide2
The additional code is:

from PySide2.QtWidgets import QMainWindow, QMenu
from PySide2.shiboken2 import wrapInstance

The same issue is the root cause of the problem i experienced when trying to execute a function located into another file.
By adding an explicit import form that file, the function is now visible, that is:

module2.py comtains

def Test():
    print("Some text...")

module1.py contains

import RLPy
import module2
from module2 import Test
def run_script():
    Test()


adding the code "from module2 import Test" makes Test() visible to module1


My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO + 1x2TB Samsung
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the MOTU M4 I/F) / DirectX: 12

jlittle
jlittle
Posted 6 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (7.0K reputation)Distinguished Member (7.0K reputation)Distinguished Member (7.0K reputation)Distinguished Member (7.0K reputation)Distinguished Member (7.0K reputation)Distinguished Member (7.0K reputation)Distinguished Member (7.0K reputation)Distinguished Member (7.0K reputation)Distinguished Member (7.0K reputation)

Group: Forum Members
Last Active: Last Month
Posts: 1.9K, Visits: 17.3K
I realize that not everyone attempting to use Python and the RL API is a programmer so here are some thoughts for you:

When creating your folder names under "Bin64\OpenPlugin\[yourapiname]" keep in mind that this is probably where everybody's project folders will be placed when you download/purchase them in the future so be sure to create a unique name for your folder so that it hopefully will not conflict with other dev's folder names. You should also put all your files/modules in the same folder for that project.

You should always put in your main.py file a comment line that indicates the version of your code. When you have many users of your code, knowing what version they are using helps in tracking down issues.
I also put on each versions comment line the date of that version and what the changes were. Typically you will change a version number after each release.
Ex:
#V1.0.0 12/23/18 Created
#V1.0.1 12/27/18 Fixed .....

The version number could also be displayed in an "About" menu selection, if using menus, or just displayed in one of your panels somewhere.
You could also create a text file in your folder with the version info.
Keep in mind that not everyone using your project will be savy about how to find the version info so try to make it easy for them.

Since each folder has only one (1) main.py file, you will need multiple folders for multiple projects or you can provide a menu of your multiple projects/functions and contain all the files for those functions in one folder.

Yes, you must "import" into a file any external files that contain items that are referenced from that file.
The "import" makes visible the items in the external file to the file importing it. This is a standard practice.

Other programming standards for Python are as follows:

Naming

  • Variables, functions, methods, packages, modules
    • lower_case_with_underscores
  • Classes and Exceptions
    • CapWords
  • Protected methods and internal functions
    • _single_leading_underscore(self, ...)
  • Private methods
    • __double_leading_underscore(self, ...)
  • Constants
    • ALL_CAPS_WITH_UNDERSCORES
General Naming Guidelines

Avoid one-letter variables (esp. l, O, I).

Exception: In very short blocks, when the meaning is clearly visible from the immediate context


Indentation

Use 4 spaces--never tabs. Enough said.

Imports

Import entire modules instead of individual symbols within a module. For example, for a top-level module canteen that has a file canteen/sessions.py,

Yes

import canteenimport canteen.sessionsfrom canteen import sessions

No

from canteen import get_user  # Symbol from canteen/__init__.pyfrom canteen.sessions import get_session  # Symbol from canteen/sessions.py

Exception: For third-party code where documentation explicitly says to import individual symbols.


Put all imports at the top of the page with three sections, each separated by a blank line, in this order:
  1. System imports
  2. Third-party imports
  3. Local source tree imports

Rationale: Makes it clear where each module is coming from.


On comments

Use them sparingly. Prefer code readability to writing a lot of comments. Often, small methods are more effective than comments.


For more info on Python Style see HERE and/or HERE

Jeff


Get my Plugin Manager and TaskNotes plugins for iClone.
Check out EZColors and Other products for CTA/CA. EZColors: the easy way to change Render Styled (RS) colors!
See my CTA Tutorials on the YouTube channel CTAStepByStep




Reading This Topic