Tags not cloning correctly [SOLVED]

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;

}

On 17/12/2014 at 01:40, xxxxxxxx wrote:

Hi Swinn,

You're not calling GetClone() the right way. It expects one of the COPYFLAGS and not a boolean value. The C.O.F.F.E.E. documentation isn't up-to-date, sorry for that.
I think if you call GetClone(COPYFLAGS_0) it should work as expected.

On 17/12/2014 at 02:37, xxxxxxxx wrote:

Thank you for your reply. I tried changing GetClone(TRUE) to GetClone(COPYFLAGS_0) but the problem still persists. Perhaps I should migrate the script to Python? Is there a way/tutorial on how to do this? Thanks.

On 17/12/2014 at 05:02, xxxxxxxx wrote:

I noticed in the COFFEE documentation that there doesn't appear to be a (COPYFLAGS_0). This seems to be in the Python documentation. All I could find were:

CL_NO_BITS
CL_ONLY_VISIBLETAGS
CL_NO_TRACKS
CL_NO_HIERARCHY

On 17/12/2014 at 08:15, xxxxxxxx wrote:

Hello,

to handle BaseLinks while copying objects yourself you need to use the AliasTrans class. This class is currently only available in the C++ SDK, not in COFFEE nor Python.

There are no official tutorials on switching from COFFEE to C++ or Python but both APIs have the same structure so the switch should not be too different. You find some examples of Python plugins and scripts in the documentation download.

Best wishes,
Sebastian

On 17/12/2014 at 09:33, xxxxxxxx wrote:

Thanks. 🙂