How to trigger “Calculate” cache button with Xpresso and User Data


#1

Hello everybody,

In the Jiggle Deformer, under Cache, there is a Calculate button.

I want to invoke that button with Xpresso. I dragged the deformer into the Xpresso window to make a node for it. I’ve attached an image that shows the input ports to the node under Cache.

My question is, how can I kick off the Caching of the Jiggle deformer? Which port (based on the attached image) should I use for the input. And what kind of User Data control can I use to set it off? Should I use a Boolean control?

Thank you so much!

Joe.JiggleNodeCachePorts


#2

I very much doubt that this is possible at all. The caching requires the system to go through all frames and evaluate the state of the jiggle to store it in the cache. XPresso, on the other hand, is dynamically evaluated per frame, so calling an evaluation like caching from the XPresso would create an endless loop. Also, threading.

If you look closely you will find that most of the settings on the Cache tab are not animatable. That is another bad sign for using it in XPresso (or dynamic Python tabs).

Should someone have a solution nevertheless, they are invited to correct me…


#3

Thank you Cairyn, I feared that would be the case.

Is there a way, such as a menu item or something, to kick off all caches for everything.

The issue is that I want to hide a jiggle deformer itself inside a rig, but have a way for an animator to cache it when they want to. Otherwise I could just find a way for them to get access to it even though I would like to keep things as uncluttered as possible.

Do you have any thought on how to do that?


#4

As far as I know, there is no built-in button to trigger all caches.

But it is possible to script that. You just need to keep the action out of the evaluation of the tree. One method would be to write a script that traverses the objects and activates the button whenever it encounters a Jiggle deformer.

Naturally, that script needs to be clicked on manually by the animator. So, you need to make sure that the animator has that script, and has it embedded in their layout.
The other method is to hide the script in a Python tag, but not in the Execute method but behind a button. You can then put that tag somewhere else where it would not be hidden from the animator, and it will find the jiggle deformer(s) by itself. The disadvantage here is that the animator must select the tag before they even see the cache button.

If you don’t want to script it (or have it programmed for you), you are probably best off by hiding the jiggle deformers in a separate layer (maybe in a layer hierarchy, depending on your animation concept) and tell the animator to make the jiggles visible if they want to cache. This would still allow for an uncluttered tree, since the jiggle visibility can be switched off.

(I admit I’m not so much a friend of hiding stuff in the OM with the layers though, since making a level in the tree folded and invisible prevents you from accessing any child objects.)


#5

Thanks for the scripting idea.

Unfortunately, I am not good at Python. I have some programming experience with C#, so I have been meaning to get into Python in C4D, but haven’t gotten around to it. I am okay with Xpresso though, so I was hoping it would be easy to do there.

I am trying to do something like what you are saying. I put the Jiggle deformers in their own layer so they are exposed in the OM. However, I don’t know how to show and hide layers with Xpresso in the OM though. So there are basically just going to sit there.

I am not sure what you mean by the jiggle visibility can be switched off. How do you mean that should be done?

Thanks again for your kind assistance.


#6

I didn’t actually mean to switch the jiggle layers on/off with XPresso. I just meant: if the animator needs to cache, they can switch on the layer that allows them to access the jiggle deformers. Maybe even as solo layer. After caching, they can make it invisible again. (Provided they do have access to the layers in their animation layout.)

Layers can be dragged into the XPresso manager but they don’t expose their visibility states. I don’t know if there is a workaround, as you will find in the Attribute Manager that the visibility states are not even animatable! So, going the XPresso route (or the Python tag route where the action is in the Execute function) doesn’t look feasible at all.

Which points right back at the scripting solution, but you cannot embed XPresso in a separate script, so you won’t find an easy solution there without Python knowledge.

If you are in urgent need for a one-click solution, and this is for pro work, I can script something for you but it’d be a job.
If you think of learning Python, I do have a specific C4D Python Patreon course with tons of sample code to traverse the tree: https://www.patreon.com/cairyn but naturally that would be a long-term project.