Hello, I'm here for help.
- I want to insert some keyframes for a color property of the plug-in, and the sub-level light object will change accordingly.The problem now is that I can't insert a keyframe for this color property (the keyframe icon always appears yellow).
- In addition, I have another question: where can I listen for the click event of the key frame icon?
These two problems have been bothering me for two or three days now, either pyhton or C++ code, Any ideas would be much appreciated!
Thanks,
Sean
import c4d
import os
class res(object):
AAAAAA_COLOR = 1000
res = res()
def load_bitmap(path):
path = os.path.join(os.path.dirname(__file__), path)
bmp = c4d.bitmaps.BaseBitmap()
if bmp.InitWith(path)[0] != c4d.IMAGERESULT_OK:
bmp = None
return bmp
class aaaaaaData(c4d.plugins.ObjectData):
PLUGIN_ID = 123566
PLUGIN_NAME = 'aaaaaa'
PLUGIN_INFO = 0
PLUGIN_DESC = 'Oaaaaaa'
PLUGIN_ICON = load_bitmap('res/icons/aaaaaa.tiff')
PLUGIN_DISKLEVEL = 0
def __init__(self):
self.value = c4d.Vector(1, 0, 0)
@classmethod
def Register(cls):
return c4d.plugins.RegisterObjectPlugin(
cls.PLUGIN_ID, cls.PLUGIN_NAME, cls, cls.PLUGIN_DESC, cls.PLUGIN_INFO,
cls.PLUGIN_ICON, cls.PLUGIN_DISKLEVEL)
def Init(self, node):
#self.InitAttr(node, c4d.Vector(1,0,0), [res.AAAAAA_COLOR])
node[res.AAAAAA_COLOR] = c4d.Vector(1, 0, 0)
return True
def CreateKey(self, obj, id, value):
track = obj.FindCTrack(id)
if not track:
track = c4d.CTrack(obj, id)
obj.InsertTrackSorted(track)
c4d.EventAdd()
curve = track.GetCurve()
key = curve.AddKey(obj.GetDocument().GetTime())
if not key:
return False
if type(value) == int or type(value) == float:
key["key"].SetValue(curve, value)
else:
key["key"].SetGeData(curve, value)
return True
def setColor(self, node, data):
plugin_color = c4d.DescLevel(res.AAAAAA_COLOR, c4d.DTYPE_COLOR, 0)
plugin_color_r = c4d.DescLevel(c4d.COLOR_R, c4d.DTYPE_REAL, 0)
plugin_color_g = c4d.DescLevel(c4d.COLOR_G, c4d.DTYPE_REAL, 0)
plugin_color_b = c4d.DescLevel(c4d.COLOR_B, c4d.DTYPE_REAL, 0)
self.CreateKey(node, c4d.DescID(plugin_color, plugin_color_r), data.x)
self.CreateKey(node, c4d.DescID(plugin_color, plugin_color_g), data.y)
self.CreateKey(node, c4d.DescID(plugin_color, plugin_color_b), data.z)
light = node.GetDown()
if light:
light[c4d.LIGHT_COLOR] = data
light_color = c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_COLOR, 0)
light_color_r = c4d.DescLevel(c4d.COLOR_R, c4d.DTYPE_REAL, 0)
light_color_g = c4d.DescLevel(c4d.COLOR_G, c4d.DTYPE_REAL, 0)
light_color_b = c4d.DescLevel(c4d.COLOR_B, c4d.DTYPE_REAL, 0)
self.CreateKey(light, c4d.DescID(
light_color, light_color_r), data.x)
self.CreateKey(light, c4d.DescID(
light_color, light_color_g), data.y)
self.CreateKey(light, c4d.DescID(
light_color, light_color_b), data.z)
def SetDParameter(self, node, id, data, flags):
paramID = id[0].id
if paramID == res.AAAAAA_COLOR:
self.setColor(node, data)
self.value = data
return True, flags | c4d.DESCFLAGS_SET_PARAM_SET
def GetDParameter(self, node, id, flags):
paramID = id[0].id
if paramID == res.AAAAAA_COLOR:
data = self.value
return True, data, flags | c4d.DESCFLAGS_GET_PARAM_GET
return True
if __name__ == '__main__':
aaaaaaData.Register()