Disabling a node parameter via Python

   6921   11   3
User Avatar
Member
4 posts
Joined: July 2017
Offline
Hi,

So I'm trying to disable a button parameter via python using the parm.disable method however it doesn't appear to do anything.

Just as a test I rigged the button to disable when a toggle was ticked which worked fine. Then I tried to directly disable it purely via code for comparison. The .hide method which I also tested appears to work however the disable method, whilst working according to the returns from .isDisabled wasn't doing anything to the UI.

Any help would be appreciated


An attempt to disable it via the python shell


Toggling the test paramter
Edited by bseeley - March 7, 2018 13:25:41

Attachments:
toggle.PNG (1.7 KB)
viaPython.PNG (1.5 KB)

User Avatar
Staff
3464 posts
Joined: July 2005
Offline
hi
testing here we're finding disable doesn't seem to do anything - can you provide the code you're using?
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
8839 posts
Joined: July 2007
Offline
.disable() seems to work on sliders, but not on buttons, feels like a bug
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
8839 posts
Joined: July 2007
Offline
after a bit of poking around with hou.Parm.disable()

on top of Buttons
- toggle parms don't reflect disable in UI (but became not toggleable anymore)
- Ordered menus neither
- RGBA Mask parms neither
- Parts of Ramps don't reflect that in UI either
- Neither of the Labels of any Parm (including Label Parm)
… maybe some others, so clearly .disable behaves differently from disable rule


- folders disable folder Heading but not contents (however after selecting other node and back current one the content gets correctly disabled, buttons, toggles and others mentioned don't however)

- aaand Key Value Parm doesn't reflect disabled state even if disabled through disable rule
Edited by tamte - March 7, 2018 15:00:49
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
4 posts
Joined: July 2017
Offline
arctor
can you provide the code you're using?

I was just recreating it ready to send some code and I found something else. To replicate what I was doing previously I added a test button and toggle to a standard environment light and for the sake of it I added a second button which is set to disable when { 1 != 1 } which I tried to enable via code and interestingly, it worked, however once the button was pressed it reverted to being disabled. The same was also observed in the first test button. It would appear that enabling a disabled node is possible, if only temporarily, however the reverse isn't true.


Anyway, as for code, these are the commands I was using to test the single button.
testNode = hou.node("obj/envlight1/")
testParm = testNode.parm("testButton")

testParm.isDisabled()
testParm.disable(True)
testParm.isDisabled()
testParm.disable(False)
testParm.isDisabled()

I've attached the environment light I was testing on as well to save you a job of adding those additional buttons.
Attachment Not Found

Attachments:
OPlibObject.hda (41.5 KB)

User Avatar
Member
603 posts
Joined: Sept. 2016
Offline
Try using:

testParm = testNode.parmTuple('testButton')
testParm.disable(True)
User Avatar
Member
899 posts
Joined: Feb. 2016
Offline
chrisgreb
Try using:

testParm = testNode.parmTuple('testButton')
testParm.disable(True)



it is still not working on toggles.
They are not grayed out.
User Avatar
Member
899 posts
Joined: Feb. 2016
Offline
for anybody who needs it fixed, it's logged as bug #99076
Edited by Andr - Aug. 30, 2019 09:52:18
User Avatar
Member
899 posts
Joined: Feb. 2016
Offline
up again, I have found another frustrating behavior:
once you disable a parameter via python, it won't stay disabled across sessions.
I attached an example

I've a digital asset that is built specifically around the .disable() function… and I just discovered this show stopper… sad

update: logged as BUG#99387
Edited by Andr - Sept. 12, 2019 18:11:23

Attachments:
not_persistent_disabled.hiplc (56.8 KB)

User Avatar
Member
899 posts
Joined: Feb. 2016
Offline
I've been told that this bug won't be fixed because:
'disable' and ‘hide’ parameter states are meant to be dynamic and controlled by scripts. They are both controlled by “disable when” and “hide when” expressions, and the HOM functions are provided to expose this functionality to other dynamic scripts.
Therefore, they have never been saved since the dawn of Houdini, and for backwards consistency and compatibility never will be.

I've been advised to use hidden parms to store the disable/hide status of a parameter and the use the ‘disable when’ field.
The problem is that I need to disable ONLY certain components of a parameter, not all of them, like the image shows.
And the ‘disable when’ user interface of the Edit Parameters Window only works on the tuple. It would disable all the components at the same time.

Do you know any workaround to permanently disable specific components?
It only comes to my mind to use a script that perform the check/disable routine in the onLoad event handler section so it's run at each session start
Edited by Andr - Sept. 15, 2019 09:05:34

Attachments:
disable.JPG (26.2 KB)

User Avatar
Member
102 posts
Joined: April 2017
Offline
I have this issue when disabling with Python xxx.parm("pathprefix").disable(True) which is showing the parameter is disabled but the tick still there
And it will export to USD with the prefix

User Avatar
Member
102 posts
Joined: April 2017
Offline
Solved!
The tick on the parm called enable_pathprefix and it has to be set to 0 when disabling.
xxx.parm("enable_pathprefix").set(0)
  • Quick Links