Jump to content

How to make button to find the min/max value and set it back to parameter?


zjie

Recommended Posts

Hi, I want to customize buttons which will allow me to find the min/max speed attribute and set it back to the parameters. I am new to Houdini and python, will appreciate some helps, thanks.

 

2018-10-24_1321.png

Edited by zjie
Link to comment
Share on other sites

node = hou.node('/obj/geo1/speed1')
geo = node.geometry()
pts = geo.points()

buffer = []
for i in pts :
    v = i.attribValue("v")
    speed = hou.hscriptExpression("length({0},{1},{2})".format(v[0],v[1],v[2]))
    buffer.append(speed)
    
buffer = sorted(buffer)
minspeed = buffer[0]
maxspeed = buffer[-1]

hou.parm("/node/with/min/parm").set(minspeed)
hou.parm("/node/with/max/parm").set(maxspeed)

 

  • Like 2
Link to comment
Share on other sites

14 hours ago, cloud68 said:

node = hou.node('/obj/geo1/speed1')
geo = node.geometry()
pts = geo.points()

buffer = []
for i in pts :
    v = i.attribValue("v")
    speed = hou.hscriptExpression("length({0},{1},{2})".format(v[0],v[1],v[2]))
    buffer.append(speed)
    
buffer = sorted(buffer)
minspeed = buffer[0]
maxspeed = buffer[-1]

hou.parm("/node/with/min/parm").set(minspeed)
hou.parm("/node/with/max/parm").set(maxspeed)

 

Hi cloud68, thanks for the help, may I know where should I input these script on? is it on the callback script on the buttons creation and changed from Hscript to python?

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...