Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

Replicator set custom parms error

Still a little green? Ask your beginner's questions here

Replicator set custom parms error

Postby morscad » Wed May 16, 2018 9:48 am

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
morscad
 
Posts: 7
Joined: Sun Feb 21, 2016 6:33 pm
Location: Montreal

Re: Replicator set custom parms error

Postby raganmd » Wed May 16, 2018 12:40 pm

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 29 times
raganmd
 
Posts: 1304
Joined: Thu Mar 28, 2013 5:21 am
Location: San Francisco, CA

Re: Replicator set custom parms error

Postby morscad » Thu May 17, 2018 11:30 am

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
Attachments
base_replicator_example.16.toe
(3.88 KiB) Downloaded 19 times
morscad
 
Posts: 7
Joined: Sun Feb 21, 2016 6:33 pm
Location: Montreal

Re: Replicator set custom parms error

Postby raganmd » Thu May 17, 2018 12:42 pm

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 28 times
raganmd
 
Posts: 1304
Joined: Thu Mar 28, 2013 5:21 am
Location: San Francisco, CA

Re: Replicator set custom parms error

Postby morscad » Thu May 17, 2018 10:12 pm

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 :-)
morscad
 
Posts: 7
Joined: Sun Feb 21, 2016 6:33 pm
Location: Montreal

Re: Replicator set custom parms error

Postby raganmd » Fri May 18, 2018 7:41 pm

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/
raganmd
 
Posts: 1304
Joined: Thu Mar 28, 2013 5:21 am
Location: San Francisco, CA


Return to Beginners

Who is online

Users browsing this forum: No registered users and 3 guests