Jump to content

What's the best way to sum attribute values up to current point?


magneto

Recommended Posts

Hi,

I have a point attribute that's a float and I want to sum their values for each point but up until the current point, so like:

ptnum - value

0 - 3

1 - 2

2 - 6

3 - 5

4 - 1

5 - 7

6 - 2

So their values would be calculated as follows:

0 -> 3

1 -> 3 + 2 = 5

2 -> 3 + 2 + 6 = 11

3 -> 3 + 2 + 6 + 5 = 16

etc

Is there a quick and elegant way to do this? Or do I have to use 2 foreach sops?

Thanks :)

Edited by magneto
Link to comment
Share on other sites

Thanks alot guys, I don't know much about chops, but kgoossens, you need to use a foreach in your example, right? That's similar to how I ended up doing.

No, no for each has been used. did you check the file?

the summation happens in the attribute promote, so you'l find the value it in the prim attribute

Edited by kgoossens
Link to comment
Share on other sites

  • 11 months later...

It takes a little bit more than in his post, but it works. Nice idea, Edward.

thanks for transnoding Edward's post .

anyway CHOPs solution isnt as accurate as thePython method ..

not sure Why? but i do not have time to investigate actually .

The same in python.

Of course it's way slower than the chop et vop versions.

your scene / otl doesnt open in my H11

, so i wrote few lines myself and it works perfectly .

and fortunately for my case speed isnt an real issue .

.cheers

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...