Python setBackgroundImages()

   1105   0   0
User Avatar
Member
1 posts
Joined: Aug. 2014
Offline
Hello everyone I have issue with this code provide by side fx help

editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
image = hou.NetworkImage()
image.setPath('$HFS/houdini/pic/Mandril.pic')
image.setRect(hou.BoundingRect(0, 0, 5, 5))
editor.setBackgroundImages()

This code is usefull to set up a background image.
When I try to navigate from /obj/myscene (where my image is) to /obj and go back to /obj/scene the image disappear unless I edit the background image with ctrl+i and move it.

Any idea or help will be welcome

My goal is to write a scripts that can capture/save/load image in the network. like that :


def screenShot():
“”“take a screen shot of the current viewport at the current frame”“”
help(screenShot)
import hou
import toolutils
import os
#selected node
nodeSelect = hou.selectedNodes()
path = hou.expandString(“$HIP”)
frame = hou.expandString(“$F”)
frame = int(frame)
black=hou.Color((0,0,0))
#name check there is a node selected
if len(nodeSelect)<1:
print (“!!! error: select a node !!!”)
else:
for node in nodeSelect:
name = node.name()
node.setColor(black)

#Get the current Desktop
desktop = hou.ui.curDesktop()
# Get the scene viewer
scene= toolutils.sceneViewer()
flipbook_options = scene.flipbookSettings().stash()
# set frame range
flipbook_options.frameRange((frame,frame))
#set output path
root =“{1}/{2}/{0}/”.format(name,path,“screenShot”)
if os.path.exists(root):
listPath = os.listdir(root)
inc = len(listPath)
inc = int(inc)
outputPath = “{}{}.{:04d}.jpg”.format(root,name,inc)

else:
print(“dont exist”)
os.makedirs(root)
inc = 0
outputPath = “{}{}.{:04d}.jpg”.format(root,name,inc)


flipbook_options.output(outputPath)
#run flipbook
scene.flipbook(scene.curViewport(),flipbook_options)

print (outputPath)
editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
print (editor)
image = hou.NetworkImage()
image.setPath(outputPath)
image.setRect(hou.BoundingRect(0, 0, 5, 5))
image.setRelativeToPath(node.path())

editor.setBackgroundImages()


screenShot()




Thxs !
  • Quick Links