Hello,
I was hoping someone could offer some insight to my problem.
When I run the following code in a Python Shell it works as expected:
my_node = hou.node(“obj/vc_control_tx/Controller”)
my_template_group = my_node.parmTemplateGroup()
my_new_max_range = 7
my_parameter_template_replacement = hou.IntParmTemplate('index_position_tx', ‘Index’, 1, (), 1, my_new_max_range, 1, 1 )
my_template_group.replace('index_position_tx', my_parameter_template_replacement )
my_node.setParmTemplateGroup(my_template_group)
When I also create a function of that same code in the Python Source Editor
and run ( by clicking Apply), it also works as expected:
def Change_Max_Default(New_Value):
my_node = hou.node(“obj/vc_control_tx/Controller”)
my_template_group = my_node.parmTemplateGroup()
my_new_max_range = New_Value
my_parameter_template_replacement = hou.IntParmTemplate('index_position_tx', ‘Index’, 1, (), 1, my_new_max_range, 1, 1 )
my_template_group.replace('index_position_tx', my_parameter_template_replacement )
my_node.setParmTemplateGroup(my_template_group)
Change_Max_Default(7)
However when I place, in the Paramter Expression “text box”, the code like I have with the Python Shell or call the function that is in the Source Editor with:
hou.session.Change_Max_Default(7)
in both cases I get the same error message that is referring to the second line of code;
Error: Unable to evaluate expression (
Traceback (most recent call last):
File “<stdin>”, line 2, in expression
File “hou.session”, line 145, in Change_Max_Default
AttributeError: ‘NoneType’ object has no attribute ‘parmTemplateGroup’
(/obj/vc_control_tx/Controller/factor_position_tx)).
My expression language is set to Python and I can't think of anything else that will allow me to access the parmTemplateGroup like I can in the Python Shell or Editor.
Any help is appreciated - thanks
Parameter Expression seems to limit access to hou classes
3054 5 1-
- BabaJ
- Member
- 2162 posts
- Joined: Sept. 2015
- Offline
-
- mtucker
- Staff
- 4565 posts
- Joined: July 2005
- Offline
I'm pretty sure the problem is this line:
my_node = hou.node(“obj/vc_control_tx/Controller”)
which is returning None when run from a parm expression. Short version is that you are passing a relative instead of absolute path. Long answer is that hou.node() operates relative to hou.pwd(), and when running an expression, hou.pwd() is the node that owns the parm being evaluated. So you can change that line to either:
my_node = hou.node(“.”)
if you want the node that is running the expression, or
my_node = hou.node(“/obj/vc_control_tx/Controller”)
if you always want to use that exact absolute path to find the node.
Mark
my_node = hou.node(“obj/vc_control_tx/Controller”)
which is returning None when run from a parm expression. Short version is that you are passing a relative instead of absolute path. Long answer is that hou.node() operates relative to hou.pwd(), and when running an expression, hou.pwd() is the node that owns the parm being evaluated. So you can change that line to either:
my_node = hou.node(“.”)
if you want the node that is running the expression, or
my_node = hou.node(“/obj/vc_control_tx/Controller”)
if you always want to use that exact absolute path to find the node.
Mark
-
- BabaJ
- Member
- 2162 posts
- Joined: Sept. 2015
- Offline
Hi Mark,
I tried both your suggestions and both work, so I no longer get that error message.
Unfortunately the last line of code:
my_node.setParmTemplateGroup(my_template_group)
crashes Houdini everytime now with error saying;
“5808: Fatal error: Segmentation fault”
I've tried removing and putting that line of code back in the expression just to make sure it is the problem line and it is.
If anyone has an idea what the trouble for this part might be it is much appreciated - thank you.
I tried both your suggestions and both work, so I no longer get that error message.
Unfortunately the last line of code:
my_node.setParmTemplateGroup(my_template_group)
crashes Houdini everytime now with error saying;
“5808: Fatal error: Segmentation fault”
I've tried removing and putting that line of code back in the expression just to make sure it is the problem line and it is.
If anyone has an idea what the trouble for this part might be it is much appreciated - thank you.
-
- BabaJ
- Member
- 2162 posts
- Joined: Sept. 2015
- Offline
Perhaps its not the last line of code per se that is giving the problem.
When I started playing around with this code in the expression editor a bit more I noticed something that appears to not be happening.
I tried opening a new file and created a new node so by chance to skip the possibility that the file was bugged. But it turns out I have the same problem.
So the new file is just a sphere dropped down with an integer parameter created within the Edit Parameter Interface.
And like before the following code works fine in the python shell when entered line by line:
So what I noticed is that when typing the second line of code in the python shell;
when at the decimal point houdini starts bringing up options listed of the available classes, methods and functions.
However when I get to the same point typing the same line of code in the expression editor nothing comes up ( no suggested classes, methods or functions ).
This tells me that “my_node” is actually no getting assigned or at least not assigned “properly” as expected,
so consequently when I get to the last line of code and I get a segmentation fault error and crash.
This would make sense to me as if “my_node” is not being properly assigned it's probably carrying an odd “address”, hence the segmentation fault?
Does this make sense to anyone?
The other thing is that if I just try doing an arbitrary assigment like ( while in the parameter expression editor ):
my_test = hou.
at the decimal point it does bring up a list of options just like parmTemplateGroup which is the one I want to use.
but again, I can't access parmTemplateGroup from “my_node” when in the parameter expression editor.
Anyone think this is a bug? or is it that I have to assign “my_node” differently in some way,
while in the paramter expression editor other than how it's done in the Python Shell.
Any Feedback is appreciated - Thanks
I'm including the file in case someone wants to play around with it and gets the same results.
I've commented out the last line of code so when you open the file it won't give the segmentation error and crash right away.
When I started playing around with this code in the expression editor a bit more I noticed something that appears to not be happening.
I tried opening a new file and created a new node so by chance to skip the possibility that the file was bugged. But it turns out I have the same problem.
So the new file is just a sphere dropped down with an integer parameter created within the Edit Parameter Interface.
And like before the following code works fine in the python shell when entered line by line:
my_node = hou.node(“/obj/sphere_object1/sphere1/”)
my_template_group = my_node.parmTemplateGroup()
my_new_max_range = New_Value
my_parameter_template_replacement = hou.IntParmTemplate('my_int_parm_a', ‘My Int A’, 1, (), 1, my_new_max_range, 1, 1 )
my_template_group.replace('my_int_parm_a', my_parameter_template_replacement )
my_node.setParmTemplateGroup(my_template_group)
So what I noticed is that when typing the second line of code in the python shell;
my_template_group = my_node.
when at the decimal point houdini starts bringing up options listed of the available classes, methods and functions.
However when I get to the same point typing the same line of code in the expression editor nothing comes up ( no suggested classes, methods or functions ).
This tells me that “my_node” is actually no getting assigned or at least not assigned “properly” as expected,
so consequently when I get to the last line of code and I get a segmentation fault error and crash.
This would make sense to me as if “my_node” is not being properly assigned it's probably carrying an odd “address”, hence the segmentation fault?
Does this make sense to anyone?
The other thing is that if I just try doing an arbitrary assigment like ( while in the parameter expression editor ):
my_test = hou.
at the decimal point it does bring up a list of options just like parmTemplateGroup which is the one I want to use.
but again, I can't access parmTemplateGroup from “my_node” when in the parameter expression editor.
Anyone think this is a bug? or is it that I have to assign “my_node” differently in some way,
while in the paramter expression editor other than how it's done in the Python Shell.
Any Feedback is appreciated - Thanks
I'm including the file in case someone wants to play around with it and gets the same results.
I've commented out the last line of code so when you open the file it won't give the segmentation error and crash right away.
-
- tamte
- Member
- 9376 posts
- Joined: July 2007
- Offline
-
- BabaJ
- Member
- 2162 posts
- Joined: Sept. 2015
- Offline
Hi tamte,
Yeah, thanks for pointing that out to me.
Now I see.
So it's the reason I can run the code no problem from python shell.
It's being originated from outside the node.
So I tried to run the code from another second sphere node to affect the first sphere and sure enough no problems.
It's unfortunate I can't do it from the same node.
But the good thing is it won't stop my project from moving forward.
It just won't function as “elegantly” user interface wise as I would like.
Then again, maybe I can think of something else.
It's been a good exercise. Nice to get feedback here to help me along.
It's appreciated, Thanks.
Yeah, thanks for pointing that out to me.
Now I see.
So it's the reason I can run the code no problem from python shell.
It's being originated from outside the node.
So I tried to run the code from another second sphere node to affect the first sphere and sure enough no problems.
It's unfortunate I can't do it from the same node.
But the good thing is it won't stop my project from moving forward.
It just won't function as “elegantly” user interface wise as I would like.
Then again, maybe I can think of something else.
It's been a good exercise. Nice to get feedback here to help me along.
It's appreciated, Thanks.
-
- Quick Links
