Jump to content


How to disable controls if an input is connected?


  • Please log in to reply
9 replies to this topic

#1 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,298 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 02 August 2012 - 02:04 PM

Hi,

I am making an asset where I want to have some of the controls disabled if an input is connected. Similar to the Box SOP, where it disables the Size and Center if you connect a node to its input.

I just don't know how to detect this at the asset level and use it in the Disabled When field.



Thanks :)

#2 ranxerox

ranxerox

    Initiate

  • Members
  • PipPip
  • 113 posts
  • Joined: 28-April 08
  • Name:gregory ecker

Posted 02 August 2012 - 02:21 PM

can you use opinput and test if it returns a null string ?

-G

View Postmagneto, on 02 August 2012 - 02:04 PM, said:

Hi,

I am making an asset where I want to have some of the controls disabled if an input is connected. Similar to the Box SOP, where it disables the Size and Center if you connect a node to its input.

I just don't know how to detect this at the asset level and use it in the Disabled When field.



Thanks :)


#3 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,298 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 02 August 2012 - 02:42 PM

I tried the opinput inside the Disabled When field but it didn't work. Can I use those expressions inside Disabled When? I thought that field has a very specific limited syntax for logic.

#4 ChristianW

ChristianW

    Illusionist

  • Members
  • PipPipPip
  • 341 posts
  • Joined: 10-November 10
  • Location:London
  • Name:Christian Waite

Posted 02 August 2012 - 02:43 PM

Set up an integer field that you then make it invisible (lets say "hasConnection".
Then use a little python, look up hou.node.inputs.
Do something like (might be wrong, it's off the top of my head and I hardly ever code):

node = hou.pwd()
inputs = node.inputs()

if not inputs:
	 return 1
else:
	 return 0

then you could disable a folder or any other parameter based on the result of the int field. Disable if:
[hasConnection == 0]

Something like that should work.
Hope that helps Magneto.
Christian

#5 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,298 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 02 August 2012 - 02:56 PM

Wow that's an awesome trick. Thanks Christian :)

#6 anim

anim

    Houdini Master

  • Members
  • PipPipPipPip
  • 921 posts
  • Joined: 23-August 07
  • Location:Slovakia, Bratislava
  • Name:Tomas Slancik

Posted 02 August 2012 - 03:03 PM

hidden int parms are usually used for this
but maybe rather than using python for the simple expression you can use hscript like
opninputs(".") == 1
or more specificlally as ranxerox suggested
opinput(".",1) == ""

Edited by anim, 02 August 2012 - 03:04 PM.

Tomas Slancik
Generalist
Slovakia

#7 hopbin9

hopbin9

    Houdini Master

  • Members
  • PipPipPipPip
  • 803 posts
  • Joined: 14-March 10
  • Location:Canada
  • Name:Hop Bin

Posted 02 August 2012 - 03:04 PM

If you put this Python expression in a parameter it will be True if input connector #3 is connected to something.

len([1 for c in hou.pwd().inputConnections() if c.inputIndex() == 2])

NOTE: inputIndex starts at zero.
Posted Image
Come download the free open source asset library for Houdini.
Help us reach 1,000 fans on facebook!

#8 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,298 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 02 August 2012 - 03:06 PM

Thanks alot guys, really cool tricks :)

Btw all these codes are to be used as Default Expression for the parameter right?

#9 hopbin9

hopbin9

    Houdini Master

  • Members
  • PipPipPipPip
  • 803 posts
  • Joined: 14-March 10
  • Location:Canada
  • Name:Hop Bin

Posted 02 August 2012 - 03:10 PM

I would put it in the Scripts section under the "On Input Changed" and have it set a parameter value to 0/1 when the inputs change.
Posted Image
Come download the free open source asset library for Houdini.
Help us reach 1,000 fans on facebook!

#10 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,298 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 02 August 2012 - 03:26 PM

Thanks hopbin, got it. I was using the default expression. Both should work I guess.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users