THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/02/2011 at 19:28, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Mac OSX ;
Language(s) : C.O.F.F.E.E ;
---------
Here I thought I was slowly gaining some real COFFEE expertise and then this (to me) unexplainable is happening.
This COFFEE Tag is attached to an Object. There is also a Material attached to the same Object. This Material has a movie in the Color Channel. My script looks up the current Frame from (doc) and copies this into the Movie Frame Start/End fields of the Color Channel so that the corresponding movie frame will display in preview. Maybe there is a much easier way to do this but I didn't find it.
So far my script has worked fine.I tried to make it a little better by doing some checking (is there a Material? etc). And finally each time I render I have to reset the Movie Frame Start/End my hand to the correct range.
To automate this somewhat I added some User Data to the COFFEE Tag with a Boolean On/Off switch.
When the switch is on the script is supposed to copy the current frame to the Color Channel. When the switch is off the script is supposed to copy the first and last frame of the document to the Material - so as to restore the normal way.
The problem is, even when the switch is Off, and the script executes the 'else' part (which I can verify by printing 'not doing it' to the Console) the movie frame will follow the document frame. Maybe there is a systematic error but after an afternoon of trying to troubleshoot this I am running out of ideas.
_ myMaterialName = myTag#TEXTURETAG_MATERIAL->GetName(); // get name of the Material
myMaterial = doc->FindMaterial(myMaterialName); // find this material in the Material list
if (!(myMaterial)) return; // abort if this Material is not there (shouldn't happen)
myChannel = myMaterial->GetChannel(CHANNEL_COLOR); // get the color channel
myChannelBc = myChannel->GetContainer(); // color channel into container for edit
if (mySwitch)
{
println ("doing it");
// here the actual transfer of start/end frames takes place
myFrame = getCurrentFrame(doc); // get the frame counter
myChannelBc->SetData(CH_TIME_FROM, myFrame); // change Movie Start Frame in animation portion
myChannelBc->SetData(CH_TIME_TO, myFrame); // and Movie End Frame to current frame
} else {
println ("not doing it");
// if switch is off set material frame start/end to default
myChannelBc->SetData(CH_TIME_FROM, getMinFrame(doc));
myChannelBc->SetData(CH_TIME_TO, getMaxFrame(doc));
println (myChannelBc->GetData(CH_TIME_FROM));
println (myChannelBc->GetData(CH_TIME_TO));
}
myChannel->SetContainer(myChannelBc); // write the edited container back to the color channel
myMaterial->Update();_