Hi!
Is it possible to have digital asset with a float slider and change dynamically its range of values?
So when for example an attribute is 136, then range of parm “slider 1” is from 0 to 136?
thank you
dynamic range ui parms
4640 5 1- danilo2
- Member
- 277 posts
- Joined: July 2006
- Offline
- graham
- Member
- 1908 posts
- Joined: Nov. 2006
- Offline
You should be able to do it, however it is slightly more work that it should be. hou.ParmTemplate objects don't seem to have setMin/Max methods. If they did then you could simply grab the existing parm template, change the max value and reapply it. However, since it doesn't you'd basically have to just recreate the parameter each time. Something like this “should” work if you attach it to a parameter inside your asset that gets cooked when the geometry changes:
sopnode = hou.pwd()
val = get attribute value.
parm = sopnode.parm(“slider1”)
pt = parm.parmTemplate()
new_pt = hou.FloatParmTemplate(pt.name(), pt.label(), len(parm.tuple()), pt.defaultValue(), min=0, max=val, min_is_strict=True, max_is_strict=True)
sopnode.replaceSpareParmTuple(pt.name(), new_pt)
sopnode = hou.pwd()
val = get attribute value.
parm = sopnode.parm(“slider1”)
pt = parm.parmTemplate()
new_pt = hou.FloatParmTemplate(pt.name(), pt.label(), len(parm.tuple()), pt.defaultValue(), min=0, max=val, min_is_strict=True, max_is_strict=True)
sopnode.replaceSpareParmTuple(pt.name(), new_pt)
Graham Thompson, Technical Artist @ Rockstar Games
- danilo2
- Member
- 277 posts
- Joined: July 2006
- Offline
Hi!
thank you very much
It “almost” works ;]
So the code:
sopnode = hou.pwd()
val = get attribute value.
parm = sopnode.parm(“slider1”)
pt = parm.parmTemplate()
new_pt = hou.FloatParmTemplate(pt.name(), pt.label(), len(parm.tuple()), pt.defaultValue(), min=0, max=val, min_is_strict=True, max_is_strict=True)
works, but when I add the line:
sopnode.replaceSpareParmTuple(pt.name(), new_pt)
then this script stops working (when it is assigned to the float field I get no error, but when I'm trying to evaluate it with python shell I get:
>>> sopnode.replaceSpareParmTuple(pt.name(), new_pt)
Traceback (most recent call last):
File “<console>”, line 1, in <module>
File “/home/prisms/builder-new/Nightly10.0/dev/hfs/houdini/scripts/python/hou.py”,
line 4579, in replaceSpareParmTuple
return _hou.Node_replaceSpareParmTuple(*args)
OperationFailed: The attempted operation failed.
Parameter name is invalid or already exists
>>> pt.name()
'sculpt_historySl'
thank you very much
It “almost” works ;]
So the code:
sopnode = hou.pwd()
val = get attribute value.
parm = sopnode.parm(“slider1”)
pt = parm.parmTemplate()
new_pt = hou.FloatParmTemplate(pt.name(), pt.label(), len(parm.tuple()), pt.defaultValue(), min=0, max=val, min_is_strict=True, max_is_strict=True)
works, but when I add the line:
sopnode.replaceSpareParmTuple(pt.name(), new_pt)
then this script stops working (when it is assigned to the float field I get no error, but when I'm trying to evaluate it with python shell I get:
>>> sopnode.replaceSpareParmTuple(pt.name(), new_pt)
Traceback (most recent call last):
File “<console>”, line 1, in <module>
File “/home/prisms/builder-new/Nightly10.0/dev/hfs/houdini/scripts/python/hou.py”,
line 4579, in replaceSpareParmTuple
return _hou.Node_replaceSpareParmTuple(*args)
OperationFailed: The attempted operation failed.
Parameter name is invalid or already exists
>>> pt.name()
'sculpt_historySl'
- Anonymous
- Member
- 678 posts
- Joined: July 2005
- Offline
from the look at code, if you put it just like that:
this
val = get attribute value.
part have no value, you have to put there your code to calculate your destination number
and this
sopnode = hou.pwd()
hou.pwd() is used for accesing actual instance of operator that uses this code so if you put it into shell it fails because it doesn't return your node that you wan't modify. try it yourself, write hou.pwd() in shell an look what it returns, definetely it's not your operator you wan't change. In shell you should use instead hou.node(yourNodePath) to get acces to node you wan't modify.
Those are two things that are causing erroer for my eye.
this
val = get attribute value.
part have no value, you have to put there your code to calculate your destination number
and this
sopnode = hou.pwd()
hou.pwd() is used for accesing actual instance of operator that uses this code so if you put it into shell it fails because it doesn't return your node that you wan't modify. try it yourself, write hou.pwd() in shell an look what it returns, definetely it's not your operator you wan't change. In shell you should use instead hou.node(yourNodePath) to get acces to node you wan't modify.
Those are two things that are causing erroer for my eye.
- danilo2
- Member
- 277 posts
- Joined: July 2006
- Offline
- Anonymous
- Member
- 678 posts
- Joined: July 2005
- Offline
-
- Quick Links