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#a05e80611f15b115595bc2dfd2ea12579I 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
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
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.