Text Driven by Clone ID


#1

Suppose I have a cloner of a text spline whose text is some function of the y-position of another object (obtained with xpresso and the function is applied with a python node). Suppose that I want the text of each clone to offset a random amount from this value. So, for example, if I had a 3 clones, and the random offsets were 0, -2, and 5, and the y-position is 3.5, then each text spline should display 3.5, 1.5, and 8.5 respectively. How could I do this without manually creating 3 separate text splines? The reason I ask is because I want hundreds of clones and don’t want to manually create that many separate text splines.

Here’s a video. I’ve gotten close, but as you can see, each clone displays the exact same value. I somehow need to create a random offset for each clone and change the number displayed for each clone, but I don’t know how to do it.

I have attached my scene file for reference:

text_driven_by_clone_id.c4d (249.0 KB)


#2

Have a look at this forum post https://www.c4dcafe.com/ipb/forums/topic/92168-display-clones-id-as-a-number-underneath-clone/


#3

If you use GetCache() in Python, using Hierarchy node treats the cloner as a list of objects that can be referenced separately

cache_snip

getcache.c4d (245.9 KB)

(note that the Python ports in my file are data type link)


#4

@JED1949, this is amazing! I’ve been looking for a general solution to vary the value of an arbitrary parameter of a cloned object with the clone ID for a long time, and this seems like the answer I’ve been searching for. But there’s one thing I don’t understand. On the very first frame of the animation, the text is just displayed as “Text” instead of the desired value:


What would it take to fix this? Can it be fixed?

#5

You seem to have an extra hierarchy node.

I don’t get the text thing in my file - try changing the order in the object manager.


#6

@JED1949, The extra hierarchy node was added because I nested the spline in an extrude object so the text would be visible in a render. Changing the order in the object manager does refresh it so that it shows the correct value on frame zero in the viewport. However, when I use shift+r to render it, the first frame of the final render still shows the “text” value, so this doesn’t really fix it. I have the same “text” issue when I use your original file as well (without the extra hierarchy node and without the extrude).

The only way I can think of to resolve the issue would be to add an extra frame, render from frame zero to total_frames + 1 and then only use frames 1 to total_frames + 1, but this is not at all ideal. I’d like to find a real solution.

I have the same issue in both R19 and R21. Which version of C4D are you using?


#7

Sorry - my mistake. I also get text as value on R21.

At least I got you part way to the solution :grinning:


#8

@jed1949, thanks, but do you have any idea why this happens? I’m not familiar with how the getcache() function works so I don’t really understand if that’s what’s causing the problem or if it’s something else.

It would be absolutely fantastic if I could fix this.


#9

All generators or parametric objects (Cube, Extrude, Nurbs,…) need to calculate a polygonal representation or a mesh. This is the cache. Just calling GetCache() may miss the mark, as the cache can actually be an entire hierarchy (which would need to be iterated or evaluated) and as soon as deformers are involved one would also need to take GetDeformCache() into account. But I don’t think that’s the issue here. For more details on cache, you could look here: SDK BaseObject Manual - Cache or Python API - Get Cache.

In this case I think, it’s probably rather a priority issue. Meaning, when you grab the cache via GetCache, the respective generator has not yet been recalculated. Playing around with the priority parameter (here explained on Edge Selection tag, but the concept is the same everywhere else) or even the Shift Priority tag, which basically is a workaround for objects not supporting the priority parameter. I’d need to investigate your scene further, but am lacking the time currently.

Cheers


#10

@MighT42, I tried playing around with the priority value on the xpresso tag but it didn’t change anything. I also tried putting the shift priority tag on the cloner and text object (setting the priority to high and low values), but also to no avail. I’m not entirely sure I understand what you mean. I don’t know what priority I would need to change in order to get this to work.

I continued to mess around with it but I’m totally lost. I set up a Python node to print the object text, as can be seen in this video, but it doesn’t print “Text” to the console at any point, so I really have no idea what’s going on.


#11

Is the scene provided in the first post still the latest? So I could investigate, when I find the time?


#12

The scene with the issue is in jed1949’s first post. I don’t understand why frame 0 of the animation has the “text” issue, and I don’t know how to fix it.


#13

As I expected, this is a priority issue. Unfortunately one, that’s not easy to solve. I doubt it’s possible without forcing the scene to update twice, hurting performance heavily.

Think about it:
In order to solve the Cloner ID issue, you request the cache of the cloner in Xpresso’s Python node. So the cloner needs to be evaluated first and it clones, what’s there at its input (a Text spline with default parameter “Text”). Only then, you are able to get all the clones and overwrite the actual text. But for C4D the work on the cloner is already done. Basically all you are seeing is lagging one frame behind. Kind of chicken and egg…
It may even be a bit worse. I have some doubts, what you are trying to do to MoGraph here, is a bit outside its specification. The more I’m playing around with the scene, the more I doubt, it can be fixed at all.
As you, John, already proposed, an additional frame -1 could help. Still, one would need to keep in mind, everything is lagging a frame behind. Not relevant, as long it’s more or less random values. But if the data shown is supposed to represent accurate scene data, this would be noticeable.
Another indicator, that there’s something happening, C4D is not really expecting or prepared for, have an instance of the Cloner. This will always show “Text”…

I have to admit, I failed to get this approach working. Sorry.

Maybe you could use a different approach. Just thinking, instead of trying to “fix” the text after cloning, do it vice versa. As far as I can see, you don’t actually need the clone IDs. You just need equally many values in Text as you have clones, right? Create just one Text object with all values for the clones, one per line. And then, not sure, you’d need to fracture it first, have MoGraph just position those words for you. I don’t know, if this can work or if it would work for you. But I really think, you will need to find different approach, which somehow provides the correct text parameter before MoGraph starts cloning.

Cheers


#14

@john-travolski I watched some noseman videos that might do what you need. He has a cloner set to blend and 2 text objects that have numbers in the text field. This gives a range of numbers for each clone, then you add a random effector. In this file I add the sphere Y to the number range.

noseman.c4d (241.7 KB)


#15

@JED1949, thank you, I had no idea you could blend text that way. Your scene file works perfectly! I’m even able to control the number of decimal places by adding a Python node like so:


I’m not entirely sure why I only need it for the top node and not both, but it seems to work fine with only one.

It’s too bad your original solution using getCache() had that issue (since it’s more general purpose), but this solution is much better for this particular problem. Thank you!


#16

That noseman’s a clever dude :grinning: