Jump to content

Storing and sorting through attributes?


Recommended Posts

For example, you are coloring a bunch of particles based on their y-position. You want to find the maximum y-position across the entire simulation and make it a value of 1(via fit range), and the minimum y-position for a value of 0.

I usually eyeball the values in the details view while I'm scrubbing the timeline trying to find max and min values. If I was making a digital asset I wouldn't want the user to take this step.

How can I iterate over all of these values and sort them?

Link to comment
Share on other sites

You could do it in python, ie:


geo = node.geometry() # replace node with hou.pwd() in an expression

attr_name = "myAttr"

max = 0

for pt in geo.points():
    attr = pt.attribValue(attr_name)

    if attr > max:
        max = attr

return max

This is designed to be used in an expression most of the time... which doesn't use def statements :P

See the following for more info:

hou.Point class

Python parameter expressions

Edited by static
Link to comment
Share on other sites

Hey man

What I did was use the attrib promote SOP and the promotion method to being either "maximum" or/and "minimum", and stored that into a details attribute on the object, and used the details expression to fetch the result from within the point SOP.

I used the time shift because then u don't have to lock ur sim, unfortunately that requires it too sim the whole sequence before u can start messing with it, i wouldnt say its the most elegant solution, but it should work :)

height.hip

Link to comment
Share on other sites

One more approach...

Since you want to work with the values of attributes over time, I would probably use CHOPs. Namely, a geometry CHOP set to "Animated" to pull in the values of y across the time range (forcing evaluation of the particles for the entire range, but can't be helped if you're looking for maxima and minima). Then a Math CHOP to combine all the particle Y channels, set to Maximum or Minimum, which will yield the highest or lowest particle y values at any given time. Then a Constant CHOP set to the "icmax" or "icmin" expression of those values to find the max or min across the entire time range.

The problem with TimeShift is you have to know the frame at which the particles are at their limits, which could be tough to know ahead of time.

See attached.

height_CHOPs.hip

Edited by johner
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...