PDA

View Full Version : Coffe-Question for my ERig


JackMcRip
10-07-2005, 09:16 PM
Hi all together,

I begin with C.O.F.F.E.E. Script in R9.5
I have finished a script, that at first klick generate Null-Objekts for a Arm Rig.
After move Null-Objekts klick Script secondary.

Now my code generate a complete Arm-Rig with all Bones and Mocca2 IK-Tags and NullObjekts for UpVectors ect and bound it to Bones.


Now I want generate the Spline-Controll Objekts.
At that I have create a Coffee-Tag.
But how can I fill the Tag with Code for synchronisation ratation or other RIG things ?
Is it possible ?

I found some constants in : C:\Programme\MAXON\CINEMA 4D R9\resource\coffeesymbols.h

There are two lines that are:
COFFEEEXPRESSIONTAG_PASS=1500,
COFFEEEXPRESSIONTAG_TEXT=1000,

Maybe I can set Coffee-Code in Text with SetContainer?


Anybody knows more ?

Kuroyume0161
10-07-2005, 11:08 PM
Hi JackMcRip,

I see that you and another have been struggling with this and, frankly, I'm surprised that no one with COFFEE experience has responded. As my COFFEE expertise is very limited, I really don't have an experienced response to offer.

It is possible that COFFEEEXPRESSIONTAG_TEXT is a String container which would allow you to place the entire script into the container as one long string (EOLs and all, I would suppose). But again, I have no clue about that.

Seems that it is Oktober and the PluginCafe regulars have gone a-festing. ;)

JackMcRip
10-08-2005, 12:23 PM
Thanks for reply :-)
You was he, how helps me a lot in first Time with Coffee.

If i can't create Coffee-Tags with Code, the rigger isn't possible :-(
Is there any other with this knowledge ?

JackMcRip
10-08-2005, 12:45 PM
Now - few minutes later I have the Idea:

var Tag = AllocTag(5675);
if (!Tag) {
println("could not allocate new MOCCA IK tag");
return;
}
var ccode = Tag->GetContainer();
ccode->SetData(COFFEEEXPRESSIONTAG_TEXT,"Hello");
Tag->SetContainer(ccode);

if (!object->InsertTag(Tag)) {
println("could not add MOCCA IK tag to current object");
return;


Generate the Coffe-Tag, and put the code "Hello" in.


Now I must learn how I generate long variable with more lines code.

JackMcRip
10-08-2005, 05:43 PM
WOW - Now I can make the Rig and Coffee connection between the bones and nullobjects.

Now, the last, I need Userdata fields add to the Null or Spline Objects ?

I read that isn't possible.
It's real?

Is there no chance to ad a userdata to a generated object ?
or is there a way to copy Userdata from one Object to another ?

Kuroyume0161
10-08-2005, 06:15 PM
Now - few minutes later I have the Idea:

var Tag = AllocTag(5675);
if (!Tag) {
println("could not allocate new MOCCA IK tag");
return;
}
var ccode = Tag->GetContainer();
ccode->SetData(COFFEEEXPRESSIONTAG_TEXT,"Hello");
Tag->SetContainer(ccode);

if (!object->InsertTag(Tag)) {
println("could not add MOCCA IK tag to current object");
return;


Generate the Coffe-Tag, and put the code "Hello" in.


Now I must learn how I generate long variable with more lines code.

My first suggestion is to verify that this container is indeed the container for COFFEE code. Enter a simple 'one-liner' such as "println(\"Guten Tag Welt!\");" and see if it does so in the Console Window when the tag is executed. Note: I won't get into ways to print Unicode characters such as the umlauted 'u'. ;)

Another suggestion is to do the code going into the tag (we'll refer to it as 'tag code') in the COFFEE editor to catch syntatical errors. Enter the tag code manually into the COFFEE tag and verify that it works. Once you have the tag code, well, codified (sorry about that), copy it into your source code above.

Now the tricky part. Source code rarely needs whitespace to be run or compiled. But EOL (end-of-line) characters should remain. Take the pasted tag code and replace all of the line endings with '\n'. Make a string variable and append the tag code, line by line, to the string. This just makes the tag code more manageable being embedded as text within the source code.


var coffeecode = "include \"c4d_symbols.h\"\n";
coffeecode = coffeecode + "var resource;\n";
coffeecode = coffeecode + "class DropToFloor_MenuPlugin : MenuPlugin\n";

// etc. - best to strip out comments or make them comments of this code rather than the tag code

ccode->SetData(COFFEEEXPRESSIONTAG_TEXT, coffeecode);

Also note that certain characters need to be qualified, such as '"' and '\' since they already represent qualifiers above the string. So, occurrences of " inside a string need to be changed to \" and those of \ inside a string need to be changed to \\.

CGTalk Moderation
10-08-2005, 06:15 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.