On 16/12/2014 at 03:35, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R16
Platform: Mac ;
Language(s) : C.O.F.F.E.E ;
---------
Hi. I am wondering if someone can help. I have a COFFEE script I am using to clone objects. I have a cloth object with 2 belt tags. When I clone it using the script, the belt tags always refer to the 2 belt objects in the first clone. But when I copy the hierarchy manually, the tags refer to the belt objects within their individual copied hierarchy, which is correct. Is there a way to make the script do this? Below is the code. Any help would be greatly appreciated. Thanks.
//COFFEE control for generating nulls
checknulls(root, count, name)
{
var nl = root->GetDown(), nltemp = nl, nlroot = nl;
if (!nl) return; //There's no child to "root" exit now
var i = 0;
//Count the nulls under root
for (i = 0;i < count;i++)
{
var nlname = name+"_"+tostring(i);
nl->SetName(nlname);
nltemp = nl;
nl = nl->GetNext();
if (!nl)
{
nl = nltemp->GetClone(TRUE);
nl->InsertAfter(nltemp);
}
}
if (count == 0) nl = nl->GetNext();
while (nl)
{
var nl2 = nl;
nl = nl->GetNext();
nl2->Remove();
}
}
getnull(root, index)
{
var nl = root->GetDown();
var cnt = 0;
while (nl)
{
if (cnt == index) return nl;
cnt++;
nl = nl->GetNext();
}
return NULL;
}
main()
{
checknulls(root, count, name);
var nl = getnull(root, ind);
if (!nl) return FALSE;
nl->SetMg(mat);
return TRUE;
}