Jump to content

Hide/Show Background Image: want a hotkey


Recommended Posts

A quick one... How do I set up a hotkey for hiding toggling the "Display Background Image" toggle in the "Background" tab of the scene viewer display options.

I know there is a little button in the toolbar at the right of the scene viewer window to do the same thing, but I would quite like a hotkey.

I couldn't find it in the hotkey editor...

Cheers!

Link to comment
Share on other sites

Normally you can Ctrl + Shift + Alt onto various UI elements to bring the Hotkey Manager up with that ui element selected. However, in this case, doing it on any of the buttons in the Display Options toolbar, or the button in the dialog results in a status bar message about the functionality not being available for those gadgets.

Link to comment
Share on other sites

Sorry, missed the reply.

You can create a shelf tool that will do it and Houdini will let you assign a hotkey to the shelf tool (use the Ctrl + Shift + Alt + Click on the tool).

The shelf tool needs to run the 'viewbackground' hscript command with the -b option. The only problem is that it also takes the super annoying viewport string thing.

The following module has an example of how to construct the string and example of using viewbackground, though with more options which you probably don't need. http://houdinitoolbox.com/houdini.php?asset=17

Link to comment
Share on other sites

  • 3 months later...

hi,

you can use this shelf tool code with hotkey.


panename = hou.hscriptExpression('mousepane()').split('.')[-1]
pane = hou.ui.findPaneTab(panename)
if pane.type() != hou.paneTabType.SceneViewer:
raise hou.Error("This tool cannot run in the current pane")
desktop = hou.ui.curDesktop().name()
panetab = pane.name()
camera = pane.curViewport().name()
viewport = ".".join([desktop, panetab, "world", camera])
viewoptions = hou.hscript("viewbackground {0}".format(viewport))[0].split()
bgoption = viewoptions[viewoptions.index('-b')+1]
if bgoption == "off":
hou.hscript("viewbackground -b on {0}".format(viewport))
else:
hou.hscript("viewbackground -b off {0}".format(viewport))
[/CODE]

It is a quick test. So I don't know whether there is a bug. If then, let me know~

cheers

  • Like 1
Link to comment
Share on other sites

I couldn't find how can I access render view both python and hscript.

So here is my last code except that. when I find it, I will post here.


def bg_toggle():
panename = hou.hscriptExpression('mousepane()').split('.')[-1]
pane = hou.ui.findPaneTab(panename)
if pane:
if pane.type() == hou.paneTabType.SceneViewer:
pass
elif pane.type() == hou.paneTabType.ContextViewer:
pane = pane.sceneViewer()
else:
print("This tool cannot run in the current pane")
return
else:
return

desktop = hou.ui.curDesktop().name()
panetab = pane.name()
camera = pane.curViewport().name()

viewport = ".".join([desktop, panetab, "world", camera])
viewoptions = hou.hscript("viewbackground {0}".format(viewport))[0].split()

bgoption = viewoptions[viewoptions.index('-b')+1]

if bgoption == "off":
hou.hscript("viewbackground -b on {0}".format(viewport))
else:
hou.hscript("viewbackground -b off {0}".format(viewport))
bg_toggle()
[/CODE]

  • Like 1
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...