Page 1 of 1

Replicator set custom parms error

PostPosted: Wed May 16, 2018 9:48 am
by morscad
Hello form, another newbie question

I am setting a replicator that copies a base OP which I have added custom params for.
on the replicator script, I want to set the value of these custom variables.
this is my scripy
Code: Select all
def onReplicate(comp, allOps, newOps, template, master):
   for c in newOps:
      c.par.clone = comp.par.master
      c.par.Title = '123'
   return

I also tried to do this
Code: Select all
def onReplicate(comp, allOps, newOps, template, master):
   for c in newOps:
      c.par.clone = comp.par.master
      op('/mainComp/scene/InstanceCompName').par.Title = '123'
   return

but I am always getting this result:
Code: Select all
AttributeError: 'td.ParCollection' object has no attribute 'Title'

what am I doing wrong?

Thanks in advance

Re: Replicator set custom parms error

PostPosted: Wed May 16, 2018 12:40 pm
by raganmd
Without looking at your process it's a little hard to tell, but I think this does work as expected. Take a look at this example to see it functioning as you describe:
base_replicator_example.tox
(1.1 KiB) Downloaded 26 times

Re: Replicator set custom parms error

PostPosted: Thu May 17, 2018 11:30 am
by morscad
Thanks a lot for all your replies Matthew

your example is obviously working fine. but I am working off a file that someone else has created, and when I take your example and duplicate my structure it in it doesn't work too.
see attached file

Re: Replicator set custom parms error

PostPosted: Thu May 17, 2018 12:42 pm
by raganmd
Okay, looking more closely at your example here, I think part of what's going on is the delay script. The replicator is attempting to set a custom parameter before the base component has been cloned, and that's why you get an error - or, rather, I'm getting an error.

In my opinion, delay scripts should be a last resort - they're tricky to work with, and can make all sorts of problems. If you have to use one, you can modify your call back to make this work with the following:

Code: Select all
delay_title_par = "args[0].par.Title = args[1][args[0].digits, 0].val"
run(delay_title_par, c, template, delayFrames = 3)


What's going on here is that we're constructing our function as a string with placeholders for the arguments we're going to pass into the function. args is a list, and so specifying index ensures that we get the objects where they need to go.

Finally, we need to run that script, then delay it one frame longer than the previous operations.

Here's a working file for reference:
base_replicator_example_mr_edits.toe
(4.02 KiB) Downloaded 26 times

Re: Replicator set custom parms error

PostPosted: Thu May 17, 2018 10:12 pm
by morscad
This is awesome.. Thanks a lot, there was no way I could have figured that part on my own by just reading the document.
I don't know why whoever did the original file use those delays.. but anyway it's all fine now.
if I ever meet you someday, I owe you a beer :-)

Re: Replicator set custom parms error

PostPosted: Fri May 18, 2018 7:41 pm
by raganmd
I was inspired to jot down some notes after our exchange - here's a little more detail about how delays work, and why run() is a better approach for Python than using the Python time module.

https://matthewragan.com/2018/05/18/tou ... y-scripts/