I have a 123.py file that imports another module. In that module, I have some code that is suppose to set the viewport to look out a specific camera. The code looks something like this:
import toolutils
defCam = hou.node(“/obj/defCam”)
scene_view = toolutils.sceneViewer()
viewport = scene_view.curViewport()
viewport.setCamera(defCam)
* assume defCam has been already been setup
If I run this snippet from Python shell inside Houdini there is no issue. However, when it runs during initial launch of Houdini (double click on desktop icon), I get the following error:
Error running Python code:
Traceback (most recent call last):
File “C:<hidden_path>/Documents/houdini16.0/scripts/123.py”, line 20, in <module>
import startup
File “<hidden_path>/houdini/scripts/python\startup.py”, line 27, in <module>
scene_view = toolutils.sceneViewer()
File “C

primarypane = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer, index)
File “C

return _hou.ui_paneTabOfType(*args)
NotAvailable: Not available in this context.
No desktops are available
Any idea why it runs fine when inside Houdini but fails during startup? Is there a better way to achieve this? TIA