Set attribute from @Frame, and hold that value

   12862   12   2
User Avatar
Member
76 posts
Joined: Oct. 2018
Offline
Simple problem, cannot find the solution.

I need to set an attribute based on the current frame, something like this:

if(@Cd.r >= 0.9){

f@t = @Frame;

}

…and I need @t to hold that value, and not change along with the current frames.

Why I need this: I'm trying to control the offset of animated instances (using “instancefile”) by starting the animation once @Cd.r passes a certain threshold. Once the animation starts, the counter for that specific instanced object needs to start at 0, and increase along with the time slider.

Any idea on how to do this?
User Avatar
Member
85 posts
Joined: April 2014
Offline
This can easily be done. If you have all your points black, then color your points when you want them to start their animation, you can then throw down a sop solver, inside the solver, add a wrangle node and this expression below.

//Inside sop solver with Previous Frame being Input
vector Cd1 = point(1, “Cd”, @ptnum);
vector Cd2 = point(0, “Cd”, @ptnum);
@Cd = max(Cd1, Cd2);
if (Cd1 == 0 && Cd2 == 1)
i@hitframe = int(@Frame);
if (point(1, “hitframe”, @ptnum) != 0)
@hitframe = point(1, “hitframe”, @ptnum);


Just be sure to put the Previous Frame into input (second input on the wrangle). This script will record the frame that the point turns from black, to white. If you time shift to the end of the sop solver sim, and then transfer the hitframe attribute back into your original points, then that should get you started.
User Avatar
Member
11 posts
Joined: June 2018
Offline
Could you maybe share a .hip file with this Code working? I copied it into a SopSolver but it @hitframe is 0 at any Time. And I don't know what I'm doing wrong.
I'm transfering a color from a sphere on to a grid and I want to grap an attribute whixh holds the value of the Frame when the color change happend.
User Avatar
Member
21 posts
Joined: Jan. 2018
Offline
You mean this ? .

Attachments:
capture_frame_w_solver.hipnc (227.6 KB)

User Avatar
Member
11 posts
Joined: June 2018
Offline
Yes that is exactly what I'm looking for but if I try it my self the variable does not stop counting after the Condition I use is longer valid. I don't no what I'm doing wrong.

Attachments:
DebugAgeCycle.hipnc (117.8 KB)

User Avatar
Member
21 posts
Joined: Jan. 2018
Offline
patrickbaiti
Yes that is exactly what I'm looking for but if I try it my self the variable does not stop counting after the Condition I use is longer valid. I don't no what I'm doing wrong.

Put a attribute wrangle bellow Prev_frame . And write : @born+=0.1; or 1.0 if you want.
User Avatar
Member
11 posts
Joined: June 2018
Offline
Could you explain me what this should change @born is still accumulating with each Frame. I feel super stupid that I have such a big problem with such a small thing.
Edited by patrickbaiti - May 14, 2021 05:03:38
User Avatar
Member
21 posts
Joined: Jan. 2018
Offline
Dante Never Cry
patrickbaiti
Could you explain me what this should change @born is still accumulating with each Frame. I feel super stupid that I have such a big problem with such a small thing.


Here you are xD

https://www.youtube.com/watch?v=8CrVp5CyR5s&list=PLzRzqTjuGIDhiXsP0hN3qBxAZ6lkVfGDI&index=20&ab_channel=JunichiroHorikawaJunichiroHorikawa [www.youtube.com]

https://www.sidefx.com/docs/houdini/nodes/sop/solver.html [www.sidefx.com]
User Avatar
Member
11 posts
Joined: June 2018
Offline
I am very familiar with the Node and how it works that's the reason why it is so frustrating right now that I can not figure out what I'm doing wrong to stop the accumulation. and the line of Code: @born += 0.1 won't change that.

I Don't understand why I can not transfer the concept you shared in the .hip file to work with the transfer of color.
User Avatar
Member
11 posts
Joined: June 2018
Offline
If I wrote your massage correct this is what you said I should do

Attachments:
DebugAgeCycle.hipnc (117.3 KB)

User Avatar
Member
21 posts
Joined: Jan. 2018
Offline
patrickbaiti
If I wrote your massage correct this is what you said I should do
Here you are

Attachments:
MicrosoftTeams-image.png (429.1 KB)

User Avatar
Member
11 posts
Joined: June 2018
Offline
Wow it finally workes thank you a lot for your Time. But why does it not work if you want to use the color as you selection option?
User Avatar
Member
21 posts
Joined: Jan. 2018
Offline
patrickbaiti
Wow it finally workes thank you a lot for your Time. But why does it not work if you want to use the color as you selection option?
My skill english not good . How can i say with you ..hmm.

It's okay if you want to use Cd attribute . But just make sure the value ( like @born in your setup ) not increse if it's no have impact by attrib transfer .
Edited by Alexander_Nguyen - May 14, 2021 08:59:53
  • Quick Links