Replicator set custom parms error

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

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

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:

AttributeError: 'td.ParCollection' object has no attribute 'Title'

what am I doing wrong?

Thanks in advance

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 KB)

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
base_replicator_example.16.toe (3.88 KB)

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:

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 KB)

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 :slight_smile:

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.

matthewragan.com/2018/05/18/tou … y-scripts/

this is an old thread but its really close to what I’m trying to do . I just want to rename all the replicants. but when I try it, it ends up being a never ending loop


def onReplicate(comp, allOps, newOps, template, master):
op(‘table2’).clear()
start =1
t = op(‘table2’)
n = op(‘null4’)

for c in newOps:
	#c.display = True
	#c.render = True
	#c.par.display = 1
	#c.par.clone = comp.par.master
	c.name = str(n[start,0]) + '_' + c.name
	debug('New Name: ',c.name)
	
	start=start+1
	pass

return

But it results in this, over & over again, which seems bad.

python >>>
New Name: 0_msg1
(Debug - DAT:/project1/container2/container1/replicator1_callbacks fn:onReplicate line:29)
New Name: 1_msg2
(Debug - DAT:/project1/container2/container1/replicator1_callbacks fn:onReplicate line:29)
New Name: 2_msg3
(Debug - DAT:/project1/container2/container1/replicator1_callbacks fn:onReplicate line:29)
New Name: 3_msg4
(Debug - DAT:/project1/container2/container1/replicator1_callbacks fn:onReplicate line:29)
New Name: 4_msg5
(Debug - DAT:/project1/container2/container1/replicator1_callbacks fn:onReplicate line:29)
python >>>
New Name: 0_msg1
(Debug - DAT:/project1/container2/container1/replicator1_callbacks fn:onReplicate line:29)
New Name: 1_msg2
(Debug - DAT:/project1/container2/container1/replicator1_callbacks fn:onReplicate line:29)
New Name: 2_msg3
(Debug - DAT:/project1/container2/container1/replicator1_callbacks fn:onReplicate line:29)
New Name: 3_msg4
(Debug - DAT:/project1/container2/container1/replicator1_callbacks fn:onReplicate line:29)
New Name: 4_msg5
(Debug - DAT:/project1/container2/container1/replicator1_callbacks fn:onReplicate line:29)
python >>>

the crazier thing is that when I try to reproduce this with the base_replicator_example.tox, … I can’t do it. Works fine on that one.

I got this working but the only thing I did was add some abstraction to c.name with
name = c.name
c.name = str(n[start,0]) + ‘_’ + name

its still odd that onReplicate cooks twice

I’ve had mixed results changing operator names with the replicator - and always feel like that’s a more dicey operation that I really like doing.

Are you matching somewhere else by operator name? Could you use a tag or custom par instead? I think you might avoid some of this issues by making that change.

yeah, looks like it works sporadically. ugh. I had a TOP I was auto-reconnecting to via TOP name. I needed a number in front to order them. looks like thats not gonna work. If I can match via tag or custom param, I’ll need to look up how to do it.