Automatically increment values/names by given value?

Hi,

First off, forgive me if the terminology in the title is incorrect, but hopefully someone will understand what I’m trying to achieve.

I have created a toe to interface between Cinema 4D (OSC) through TD and out to control DMX controlled lights and winches.

Everything is working as expected for 1 light and 1 winch, however I now need to scale to 68 winches and 20 lights. In C4D the values are labelled light_01, light_02… etc, winch_01, winch_02… etc

I’ve “collapsed” each light and winch into it’s own container with an out chop which then I merge together and route to the DMX out chop. (First 3 channels are the Winch, next 6 are the moving head light)

Now, I could MANUALLY create all of these sub-networks and then wire them together, but I was hoping there may be a way to perhaps duplicate each container and have values inside the container, as well as it’s own name increment, allowing me then to easily wire together to the DMX out chop.

I hope the above makes sense. Any help or tips on how to create incremental copies of networks with auto renaming or similar would be appreciated.

I’m fairly new to TD, but slowly getting the hang of it.

Thx!

  1. Look into the Replicator COMP.
    If you open Help → Operator Snippets ->COMP ->Replicator you’ll see some examples.

Under the “by name by index” example you’ll see how you can replicate COMPs with networks inside, while some nodes in those COMPs have unique parameters.

  1. Another way is to use cloning , see the wiki Clone page. I’ve attached a simple example of a single base which is a clone of itself, if you copy paste this base x times, they all have the same network, and if you edit the contents of the first base, all others follow. Also note how the Text TOP inside the base uses parent().digits to get information in which base it is, you can use this to set matching parameters for each numbered winch.
    cloning_example.tox (590 Bytes)

Thank you @nettoyeur !! This made my day.

After some experimenting by modifying some of the code in your .tox it’s working. Thank you so much.

So now I have this part automated, is there any way to automatically merge all these outputs sequentially on creation to a merge CHOP (so I don’t need to manually connect and order each of the outputs?)

I’ll keep experimenting, but figured I’d ask. I’m certain it can possible with something similar to your snippet. Thanks again!

If anyone else wants to know how this worked, I just inserted the expression :

str(parent().name) +‘/userData/light_pan’ [the last part being what I needed selected from the osc input]

Now when I duplicate the parent container I automatically have all the correct channels inside selected and sent to the output! Massive time saver

To avoid manually wiring, use a select chop and pattern matching. Look in op snippets for some examples.

docs.derivative.ca/Pattern_Matching

Thanks for the suggestion bwanajh, however from what I see this can help in which “channels” to select, but not automatically select which CHOP’s, or am I missing something?

I am trying to merge multiple containers’ outputs sequentially. I’ve tried putting some pattern matching strings in to the selects’ CHOP source, but no joy.

Will keep trying, but if anyone has suggestions?

chopmatching.2.toe (4.37 KB)
You can pattern match from anywhere in the network with a select Chop.

Hi bwanajh,

Wow, Thank you so much for the .tox with all the examples!

Just goes to show not only how amazing TD is, but how helpful the community of users is too. Very grateful for you taking the time out to explain and upload the example.

Anyone wanting to grasp pattern matching should take a peak at this .tox. This was SO helpful for a somewhat newbie.

Hi All,

Ok, so using the expressions suggested above my project scales as expected.

When I duplicate the containers the merge chop adds everything in order as expected, yet once I get up to 34 winches, the performance just grinds to a halt and causes TD to freeze.

I don’t know what might be causing this, but I’m frantically trying to find a solution. Can anyone offer any suggestions as to what to look for OR any “logs” I can look at to debug?

Thx!

this question totally depends on how your have build your network - it’s easier for people to help if you post your .toe file

Yeah as Idzard says without seeing the network it’s very difficult to know where the slowdown is occuring. The performance monitor [url]https://docs.derivative.ca/Performance_Monitor[/url] is a great place to start, and also in the palette there is a helpful component for optimising called probe [url]https://docs.derivative.ca/Palette:probe[/url]

Hi Guys,

So I was able to get things working for up to 34 winches, however as soon as I double that it crawls to a halt…

It appears if I disable the viewers that helps, but aside from that I can’t seem to figure out.

I’ve attached the .toe.

Would really appreciate any help. Is it potentially the shear amount of data coming thru on OSC that could be causing it?

Any ideas or tips on where to look would be very much appreciated.

Thx!
LYM-DMX-ALL.1.toe (465 KB)

The issue is in your Select CHOP which takes 1.5 seconds(!) to cook.
I noticed you have set all your OSC in CHOPs in each winch to a custom sample rate of 1000 Hz, which means all all CHOPs are running at 1000 fps and all 340 channels coming in to the Select CHOP are 1000 fps samplerate . This is useless as you send artnet out at 60 fps. I’d say leave the OSC in CHOP at it’s default sample rate of 60 fps and you will do better.

Also you only need one OSC In CHOP in your whole network which gets all the osc signals for all the winches. Then use a Select CHOP in each winch COMP to get the channels to you need from that single OSC In CHOP.

Ps if you would use cloning as in my example you would only have to edit the master winch comp instead of all 70 winch comps

attached a quick new version of your network running at 60 fps, using the tips I said above.
(not sure I copied all of your stuff into this version, but just to show how it could work)

Also as demonstration I used a Replicator COMP to generate 70 Winch COMPS without having to copy paste them, and I made all your Light0x COMPS clones of the first Light01 COMP. You’ll see if you edit only the MasterWinch01 COMP or the Light01 comp that all other COMPS immediately use that same network.

Hope this helps you back on track learning TD, let me know if you have any further questions.
cheers, Idz
LYM-DMX-ALL_replicants_and_cloning.toe (14.9 KB)

Hi nettoyeur,

Thank you for taking the time to look and give some valuable feedback. Everything you mention makes sense.

I’ll re-look at your cloning example as maybe I miss-understood. I was already very grateful that I only needed to make one and then as I duplicated it, it would increment and connect to the select chop.

Totally makes sense about only having one OSC in, I guess I was just unsure as to how I could pass that data IN to the containers below. As I mentioned I’m fairly new to this…

I had the rate set so high for the OSC-in since I read on another forum post that when the the user set the OSC to up to 1000, their problems went away, so that is still stuck in their from the last experiment. (But totally makes sense when you bring it up)

Thanks again greatly for all the pointers. I’ll have another look. Hopefully this should help me get to the bottom of it this.

I’ll post back here so others can learn from my mistakes…

Oh wow, I was just writing the reply and saw you posted an example…

Let me take a look. Thank you so much for the invaluable knowledge share.

I’ll report back on how this works out.

Hi nettoyeur,

Thank you! Your example works exactly as you explained… It drops to 40fps, but I think I can rectify that by running on a more powerful machine (PC also, not a mac laptop). (At least it wasn’t the 2fps and hanging like before!)

Just one thing I want to ask. Since the DMX-out is expecting the signal from Winch01 to be first six channels, then the others to sequentially follow is it ok if I manually delete Winch00? Does it re-spawn OR is there a way to skip creating a Winch00?

Since there are so many channels it’s quite hard to see what is going on and I don’t want to break it if I delete. I’ll dig around, but thought I’d ask.

Thank you once again. I’m actually excited to continue on with this now after having had several sleepless nights. Still SO much to learn with T.D! Forever grateful for your pointers. Will report back with the final result for others to learn too!.

Hi Nettoyeur,

I thought you may could help me with my struggle to set a parameter to some ops named op_name1 to op_name12 let’s say with the setattr(op_name, param, value) function. So I tried

for i in range(12):
setattr(op(‘op_name’ + str(i)).par, ‘reset’, 1)
setattr(op((‘op_name1’).digits).par, ‘reset’, 1)

any tipwould be appreciated.
thkanks

for i in range (12):
	n = 'feedback' + str(i)
	c = op(n)
	c.par.resetpulse.pulse()