Jump to content
dzigakaiser

Python - frameSelected() function not working

Recommended Posts

Hey guys!

Once again, I have to seek out your precious help ^.^

I am currently creating my own asset browser and I am working on feeding assets from Houdini into the library.

So far, everything was going pretty smoothly up until I got stuck with something that seems so simple: the frameSelected() function of the hou.GeometryViewport class.

When I use the Python shell inside Houdini and do this, it is working correctly:

import toolutils
viewer = toolutils.sceneViewer()
view = viewer.curViewport()
node = hou.node('/obj/geo1/DZK_Asset_Export')
node.setCurrent(True,True)
view.frameSelected()

My section in the HDA is not. Broken down to the essential part (with hard coded selection of node as above for the sake of the example):

import toolutils

viewer = toolutils.sceneViewer()
view = viewer.curViewport()
[...]
cam = obj_level.createNode('cam', 'asset_cam')
node = hou.node('/obj/geo1/DZK_Asset_Export')
node.setCurrent(True,True)
view.frameSelected()
view.saveViewToCamera(cam)
view.setCamera(cam)

All the other functions work as expected (lockCameraToView, saveViewToCamera, setCamera all work fine).

I only have trouble with frameSelected(), even when adding the code from the shell to my script, basically hard coding selecting the correct node.

After running my export process which does not frame the view, I can go to the shell and call frameSelected() and from there it works again :/

I also have sections where I first set the camera, lock the view, then try framing but it is the same result: all working, except the framing.

I wonder what I am doing wrong in my code and hope you can help me out.

 

Any pointers, comments are greatly appreciated!

 

Share this post


Link to post
Share on other sites

Okay, I got a little further now. When using setSelected(True,True) instead of setCurrent(True, True) I almost get it to work:

When I click my HDA SOP and run the code, it does not frame the SOP. If I click next to it and then run the code from the parameter interface, it works. 

I added a print statement for hou.selectedNodes() before calling frameSelected() and the output is identical (1st line: clicking on the SOP/ 2nd line: clicking into an empty area in the node graph after having the SOP selected):

(<hou.SopNode of type DZK_asset_export at /obj/geo1/DZK_Asset_Export>,)
(<hou.SopNode of type DZK_asset_export at /obj/geo1/DZK_Asset_Export>,)

Both methods result in also having the node return True for isCurrent(). I am not quite sure what to actually take from this and where to go next :o

Edited by dzigakaiser

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×