Sum point attribute accumulative over time

   6760   6   2
User Avatar
Member
10 posts
Joined: Oct. 2015
Offline
Hello ! I'm trying to visualize data from a sequence of csv files. It all works well with the table SOP, loading a new csv file on each frame. Now I would like to sum one attribute over time, like stacking up on each frame. The solver SOP seems to be the right direction, but how do I generate the actual sum of the attribute on each frame?

Thanks in advance! J
Houdini Indie 19.0.455, Windows 10
User Avatar
Member
1743 posts
Joined: March 2012
Offline
I put together a HIP file, but then I realized that you might be using Apprentice or Indie, so here's a screenshot. Attribute Wrangle is a versatile node that lets you write quick things of VEX code to do all sorts of things. In this example, it goes over each point of the first input (input 0), and adds the value of the “attrib” point attribute from the corresponding point in the second input (input 1) to the y component of the “P” (position) point attribute in the output. (It copies the starting value from input 0.) Some people prefer to use VOPs (a visual representation of VEX, in an Attribute VOP SOP) for things like this, but I find it much easier and faster to write VEX directly.

Attachments:
AccumulateAttributeWrangleExample.png (61.1 KB)

Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
10 posts
Joined: Oct. 2015
Offline
Thanks so much! I will try it later. And yes, I'm using Indie …
Houdini Indie 19.0.455, Windows 10
User Avatar
Member
10 posts
Joined: Oct. 2015
Offline
I can't quite get it to work. The table import goes into the solver's first input? Do I need to put the table import into the solver (see screenshot)?

If you still have the hip file, I have access to a full license at work.

Thanks in advance!

Attachments:
Screenshot 2017-02-21 20.34.52.png (21.7 KB)
Screenshot 2017-02-21 20.35.49.png (118.3 KB)

Houdini Indie 19.0.455, Windows 10
User Avatar
Member
1743 posts
Joined: March 2012
Offline
Pretty close! My “@P.y += @opinput1_attrib;” was just an example. If you have a float attribute named “foo” and you also want it accumulated into “foo”, it'd be “@foo += @opinput1_foo;”, and Attributes to Create would need to be “foo” instead of “P”.

For the first input into the Solver SOP, you'd want something with the same number of points but with “foo” equalling zero for all points, else the first frame's values will get counted twice, so you may want to put an Attribute Wrangle with “@foo = 0;” between the Table Import and the Solver SOP. Oh, and remember that the Table Import outside the Solver SOP shouldn't be time-dependent, else the Solver will have to recook the whole range of frames up to that point on each frame, instead of just cooking once. The Table Import SOP inside the Solver should use $F to select the file to load for that frame.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
10 posts
Joined: Oct. 2015
Offline
That did the trick. Thanks a lot for the detailed explanation!
Houdini Indie 19.0.455, Windows 10
User Avatar
Member
2 posts
Joined: Feb. 2017
Offline
Use a combination of a delete node/range and an attribute promote set to sum.
http://3d-rendering-services.uk [3d-rendering-services.uk]
  • Quick Links