Profile Picture

SetTransitionStrength()

Posted By RobertoColombo 2 Weeks Ago
You don't have permission to rate!
Author
Message
RobertoColombo
RobertoColombo
Posted 2 Weeks Ago
View Quick Profile
Distinguished Member

Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)

Group: Forum Members
Last Active: 4 hours ago
Posts: 1.6K, Visits: 3.0K
HI all,

after scratching my head for a while because of the bizzarre behavior, I finallz found that the value we set with SetTransitionStrength() shall be related to the time where we set a key frame.
I found that if the value that we set is higher than the time (in msec) where we want to put a key, the key characteristic is spoiled.
So far, I tried with the Diffuse Color, not sure for other key settings...
Just try the following code, which creates a cube and set it to a green color after 100 msec with a linear transition.
Try first transition strength <= 100, and after put it > 100 (even 101...) and see what's happening... WinkWinkWink

Cheers

  Roberto

from winreg import *
import os, RLPy

#=======================================================================================
# Plug-in entry point
#=======================================================================================

def run_script():

    #-- Get iClone 7 default template path --#
    Registry = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
    RawKey = OpenKey(Registry, r"SOFTWARE\Reallusion\iClone\7.0")
    ic_template_path = os.path.abspath(QueryValueEx(RawKey, "Template Data" )[0])

    #-- Load Box_001.iProp --#
    RLPy.RFileIO.LoadFile(ic_template_path + "//iClone Template//Props//3D Blocks//Box_001.iProp")

    #-- Get Prop --#
    prop_obj = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box_001")    
    
    if prop_obj is not None:    
        mesh_names = prop_obj.GetMeshNames()
        material_component = prop_obj.GetMaterialComponent()
        material_names = material_component.GetMaterialNames(mesh_names[0])

        diffuse_color = RLPy.RRgb().From(0, 100, 0)
        
        R_Key = RLPy.RKey()
        R_Key.SetTime(RLPy.RTime(100))
        R_Key.SetTransitionType(RLPy.ETransitionType_Linear)
        R_Key.SetTransitionStrength(50)
                
        material_component.AddDiffuseKey(R_Key, mesh_names[0], material_names[0], diffuse_color)
    else:
        print("Can't create the prop!!!")





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 / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12

RobertoColombo
RobertoColombo
Posted 2 Weeks Ago
View Quick Profile
Distinguished Member

Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)

Group: Forum Members
Last Active: 4 hours ago
Posts: 1.6K, Visits: 3.0K
mmmh... the situation seems even worst.
Launchin this same script multiple times, each time with different values for the keyframe time and transition strength, I often get random results for the assigned color: sometimes it is assigned correctly, sometimes th eprop glows like crazy, other times it is black... weird... Blink
Not sure if others experience the same... 



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 / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12

Edited
2 Weeks Ago by RobertoColombo
Kelleytoons
Kelleytoons
Posted 2 Weeks Ago
View Quick Profile
Distinguished Member

Distinguished Member (16.3K reputation)Distinguished Member (16.3K reputation)Distinguished Member (16.3K reputation)Distinguished Member (16.3K reputation)Distinguished Member (16.3K reputation)Distinguished Member (16.3K reputation)Distinguished Member (16.3K reputation)Distinguished Member (16.3K reputation)Distinguished Member (16.3K reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 5.4K, Visits: 10.7K
Either there's a language barrier or a brain barrier here, Roberto, but I'm not quite understanding your issue.  However, in any case, have you tried using a step transition where you want to pin the color properly?  Using any other kind of transition (even doing it by hand) in the timeline DOES produce weird effects in color changes, but that would be expected.



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
RobertoColombo
RobertoColombo
Posted 2 Weeks Ago
View Quick Profile
Distinguished Member

Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)

Group: Forum Members
Last Active: 4 hours ago
Posts: 1.6K, Visits: 3.0K
H Mike,

first of all, it is not true that the transition curves on key frames generate strange results.
They work pretty fine indeed!
Just put a simple box in a scene, assign a diffuse color at a certain frame, e.g. 300, then play with the transition keys and you will that the color transition follows the transition curve as expected.

Said, this, I come back to the problem.

I want to do the simplest thing: setting the diffuse color of a prop.
Let's even make it simpler: I want to assign the color at time 0, i.e. the 1st frame.

So, let's go steps by steps...
Here there is a nice example: http://manual.reallusion.com/iclone/script/python/md_docs__way_to_control_prop.html 
...but unfortunately that code is bugged!!
Just copy-paste it, run it and you should got the error: <class 'TypeError'>, File: C:\Program Files\Reallusion\iClone 7\Bin64\RLPy.py, Line: 8340

So, here we have another shoot: http://manual.reallusion.com/iClone/script/python/class_r_l_py_1_1_r_i_material_component.html#a05e80611f15b115595bc2dfd2ea12579
I can successfully load a texture, so I thought that it would be a piece of cake to use the same  way to assign the diffuse color.
The code I pasted above is just a semplification of the the example in that page... but t does not work.
I get strange results...

Perhaps there is another way to set a color, but unfortunately this is what RL documented: one bugged example and another that ends into strange results Sad

Any hints ?

  Roberto

PS: of course if you had learned Italian language instead of keep on playing tennis, right now there would be no language bareer BigGrinTongue



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 / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12

Edited
2 Weeks Ago by RobertoColombo
videodv
videodv
Posted Last Week
View Quick Profile
Veteran Member

Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 156, Visits: 3.9K
RobertoColombo (2/7/2019)
H Mike,

first of all, it is not true that the transition curves on key frames generate strange results.
They work pretty fine indeed!
Just put a simple box in a scene, assign a diffuse color at a certain frame, e.g. 300, then play with the transition keys and you will that the color transition follows the transition curve as expected.

Said, this, I come back to the problem.

I want to do the simplest thing: setting the diffuse color of a prop.
Let's even make it simpler: I want to assign the color at time 0, i.e. the 1st frame.

So, let's go steps by steps...
Here there is a nice example: http://manual.reallusion.com/iclone/script/python/md_docs__way_to_control_prop.html 
...but unfortunately that code is bugged!!
Just copy-paste it, run it and you should got the error: <class 'TypeError'>, File: C:\Program Files\Reallusion\iClone 7\Bin64\RLPy.py, Line: 8340

So, here we have another shoot: http://manual.reallusion.com/iClone/script/python/class_r_l_py_1_1_r_i_material_component.html#a05e80611f15b115595bc2dfd2ea12579
I can successfully load a texture, so I thought that it would be a piece of cake to use the same  way to assign the diffuse color.
The code I pasted above is just a semplification of the the example in that page... but t does not work.
I get strange results...

Perhaps there is another way to set a color, but unfortunately this is what RL documented: one bugged example and another that ends into strange results Sad

Any hints ?

  Roberto

PS: of course if you had learned Italian language instead of keep on playing tennis, right now there would be no language bareer BigGrinTongue



Hi Roberto


I have had a tinker with this and come up with the following script just run the script first press the get colour button and select a colour from the colordialog second press the place prop button the just scroll the timeline a little and you should see the colour you selected.
What I have found is sometimes the colour selected from the colordialog will not show correctly but I think this is to do with setting the red green and blue variables to int or simular.
anyway hope this helps.

here is the code

import PySide2, RLPy
import colorsys
from PySide2 import *
from PySide2 import QtWidgets
from PySide2.QtCore import Qt
from PySide2 import QtGui
from PySide2.shiboken2 import wrapInstance

import os, math
from winreg import *


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

def openColorDialog():
    """
    Opens the color dialog
    """
   
    global color
   
    color = QtWidgets.QColorDialog.getColor()
     
def get_prop():
    #-- Get iClone 7 default template path --#
    Registry = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
    RawKey = OpenKey(Registry, r"SOFTWARE\Reallusion\iClone\7.0")
    ic_template_path = os.path.abspath(QueryValueEx(RawKey, "Template Data" )[0])

    #-- Load Box_001.iProp --#
    RLPy.RFileIO.LoadFile(ic_template_path + "//iClone Template//Props//3D Blocks//Box_001.iProp")

    #-- Get Prop --#
    prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box_001")

    #-- Get Material from Prop --#
    material_component = prop.GetMaterialComponent()
    mesh_list = prop.GetMeshNames()
    mesh_name = mesh_list[0]

    material_list = material_component.GetMaterialNames(mesh_name)
    material_name = material_list[0]
   
    alpha = color.alpha()
    red = color.red()
    green = color.green()
    blue = color.blue()
   
    # 208 48 197
    diffuse_color = RLPy.RRgb().From(255, 127, 0)  

    R_Key = RLPy.RKey()
    R_Key.SetTime(RLPy.RTime(100))
    R_Key.SetTransitionType(RLPy.ETransitionType_Step)
    R_Key.SetTransitionStrength(100)
       
    #-- Add diffuse key --#
    material_component.AddDiffuseKey(R_Key, mesh_name, material_name, RLPy.RRgb().From(red, green, blue))
   
def run_script():
    global sample_dialog

    sample_dialog = RLPy.RUi.CreateRDialog()
    sample_dialog.SetWindowTitle("Sample Dialog")

    #-- Create Pyside layout for RDialog --#
    pyside_dialog = wrapInstance(int(sample_dialog.GetWindow()), QtWidgets.QDialog)
    #pyside_dialog.setFixedWidth(300)
    sample_layout = pyside_dialog.layout()
 
    #-- Add PushButton --#
    colourbutton = QtWidgets.QPushButton("Get Colour")
    sample_layout.addWidget(colourbutton)
   
    #-- Add PushButton --#
    pushbutton = QtWidgets.QPushButton("Place Prop")
    sample_layout.addWidget(pushbutton)

    colourbutton.clicked.connect(openColorDialog)
    pushbutton.clicked.connect(get_prop)
  

    sample_dialog.Show()

Chris.
RobertoColombo
RobertoColombo
Posted 2 Weeks Ago
View Quick Profile
Distinguished Member

Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)

Group: Forum Members
Last Active: 4 hours ago
Posts: 1.6K, Visits: 3.0K
Hi Chris,

I would like to nail down a bit the problem.
This is the relevant part of your code:

    alpha = color.alpha()
    red = color.red()
    green = color.green()
    blue = color.blue()
    
    # 208 48 197
    diffuse_color = RLPy.RRgb().From(255, 127, 0)   
    R_Key = RLPy.RKey()
    R_Key.SetTime(RLPy.RTime(100))
    R_Key.SetTransitionType(RLPy.ETransitionType_Step)
    R_Key.SetTransitionStrength(100)
        
    #-- Add diffuse key --#
    material_component.AddDiffuseKey(R_Key, mesh_name, material_name, RLPy.RRgb().From(red, green, blue))

Note that in yoiur code you set the diffuse_color but actually you never use it.
In fact. you add a key at a certain time, with strength = 100, and the RGB set by the "color" object, which gets updated by the QColor widget.


Now, if you look at my code, I simply removed all the GUI stuff and just worked directly on the prop, setting a key with a fixed color and I am basically doing the same:
1. create a RKey object,
2. set its color,
3. assign to the prop.

       diffuse_color = RLPy.RRgb().From(0, 100, 0) 
        R_Key = RLPy.RKey()
        R_Key.SetTime(RLPy.RTime(100))
        # I tried also to set the transition type to STEP but the inconsistency in behavior is still there...
        R_Key.SetTransitionType(RLPy.ETransitionType_Linear)
        R_Key.SetTransitionStrength(50) 
        material_component.AddDiffuseKey(R_Key, mesh_names[0], material_names[0], diffuse_color)

Doing this i see random behavior, not consistent: sometimes the prop is set to clack and if I look at the diffuse box in the material window I can effectively see it as black together with the keyframe (hide/unhide shows the keyframes) !!!
I tried to change the transitoin to STEP but i do not see any difference in behavior.

What is your experience if you try to copy-paste my code and execute multiple time, deleting the added prop before every launch, amnd also changing the Key time and strength ?
I tested the border cases, e.g. time = 0, strength != 0, or time = X ( > 0 ) and strength higher or lower than X, etc.
Also, I tried to run the script N times, with different values...
Behavior is not consistent!

I will do some more experiment later, creating a loop, where for each iteration I create the same prop again and displace on the X axis by a fixed amount, so that all the props are visible, and logging the assigned RGB color values, so that I can compare the values passed to the key and what is the final color in the scene.

Also, I would lke somebody from RL to explain:

1. whether the transition type and strength is mandatory when we set a key (it should not be! The proper behavior should be that it default to a fixed setting, and this should be documented somewhere)
2. what is really the strength: how the plugged number behaves and whether is there any relationship with the keyframe absolute time and relative time from the previous keyframe
3. why the codes on their website are bugged and misbehaving: did they test it ? Publishing bugged or wrong code simply waste our time...

  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 / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12

Edited
2 Weeks Ago by RobertoColombo
videodv
videodv
Posted 2 Weeks Ago
View Quick Profile
Veteran Member

Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 156, Visits: 3.9K
Hi Roberto
The code I put up I started about a week ago and been trying to get a satisfactory result ever since, but I have found the same as you, the results have been inconsistant at best no matter what values I try the same as you as well.

I tried you code as well and got the same results too i.e inconsistant.

I agree the documentation is lacking to say the least at best head scratching at worst not working at all, RL really need to take some time and work on this aspect of the API so we all can get a handle on whats what.

I will be looking at this again this evening when I have more time although I feel unless we get more help from RL not sure how far we can go to get a consistant outcome, it has been a frustrating week for me trying to just change the colour of a prop to one of my choosing.

Chris.
RobertoColombo
RobertoColombo
Posted 2 Weeks Ago
View Quick Profile
Distinguished Member

Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)

Group: Forum Members
Last Active: 4 hours ago
Posts: 1.6K, Visits: 3.0K
Hi Chris,

thanks for the answer.
So, it seems I am not the only one to find weird behavior with the diffuse color settings.
Till RL clarifies whether there is a bug or are we doing something wrong, I will stop here for this part of the API and move to other ones.

Cheers

  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 / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12

videodv
videodv
Posted Last Week
View Quick Profile
Veteran Member

Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)Veteran Member (666 reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 156, Visits: 3.9K
RobertoColombo (2/8/2019)
Hi Chris,

thanks for the answer.
So, it seems I am not the only one to find weird behavior with the diffuse color settings.
Till RL clarifies whether there is a bug or are we doing something wrong, I will stop here for this part of the API and move to other ones.

Cheers

  Roberto


Hi Roberto

After a couple of hours on this with the same issues, I think like youself I will give this a rest for now as I also have other things going on so will wait for RL to get back (hopefully soon) with an answer with this issue.

Cheers
Chris

AllenLee (RL)
AllenLee (RL)
Posted Last Week
View Quick Profile
New Member

New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 6, Visits: 92
RobertoColombo (2/7/2019)
HI all,

after scratching my head for a while because of the bizzarre behavior, I finallz found that the value we set with SetTransitionStrength() shall be related to the time where we set a key frame.
I found that if the value that we set is higher than the time (in msec) where we want to put a key, the key characteristic is spoiled.
So far, I tried with the Diffuse Color, not sure for other key settings...
Just try the following code, which creates a cube and set it to a green color after 100 msec with a linear transition.
Try first transition strength <= 100, and after put it > 100 (even 101...) and see what's happening... WinkWinkWink

Cheers

  Roberto

from winreg import *
import os, RLPy

#=======================================================================================
# Plug-in entry point
#=======================================================================================

def run_script():

    #-- Get iClone 7 default template path --#
    Registry = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
    RawKey = OpenKey(Registry, r"SOFTWARE\Reallusion\iClone\7.0")
    ic_template_path = os.path.abspath(QueryValueEx(RawKey, "Template Data" )[0])

    #-- Load Box_001.iProp --#
    RLPy.RFileIO.LoadFile(ic_template_path + "//iClone Template//Props//3D Blocks//Box_001.iProp")

    #-- Get Prop --#
    prop_obj = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box_001")    
    
    if prop_obj is not None:    
        mesh_names = prop_obj.GetMeshNames()
        material_component = prop_obj.GetMaterialComponent()
        material_names = material_component.GetMaterialNames(mesh_names[0])

        diffuse_color = RLPy.RRgb().From(0, 100, 0)
        
        R_Key = RLPy.RKey()
        R_Key.SetTime(RLPy.RTime(100))
        R_Key.SetTransitionType(RLPy.ETransitionType_Linear)
        R_Key.SetTransitionStrength(50)
                
        material_component.AddDiffuseKey(R_Key, mesh_names[0], material_names[0], diffuse_color)
    else:
        print("Can't create the prop!!!")





Hi Roberto,
We found a bug in the RLPy.RRgb.From( x, y, z ).
You can try this:
diffuse_color = RLPy.RRgb(0, 100/255, 0)


Allen





Reading This Topic