Search - User list
Full Version: Take a screenshot of the Network Editor
Root » Technical Discussion » Take a screenshot of the Network Editor
julien-b
Hi guys,

I'm trying to find a way to take a screenshot of the selected nodes of the networkEditor. Did anyone managed to do the same already ?

So far, I got everything I needed, the coordinates in screen space of the bounding rect I need to capture (based on the selected nodes), but it's expressed in local space of the networkEditor.

The next (and last) step for me would be to “just” get the position of the networkEditor in screen space, but this is something that is not available in the Python API.

I tried to go through the Qt Widgets in an attempt to find the one that describes the networkEditor, but without any success.

Please let me know if you had ideas on how to solve this…

Thanks a lot,

Julien
malbrecht
Hi, Julien,

if you are on Windows, you should be able to find screen coordinates of client windows using the win32gui module. It's been some time that I used Python for C++ jobs (sorry, couldn't resist ), but it should work somewhat along this line of thought:

  • get your window handle (probably Houdini's main window handle, you can look that up from the project name and Houdini version) using win32gui.FindWindow(…)
  • get main window's screen estate from win32gui.GetWindowRect(handle)
  • get client windows (all “sub-windows” in Houdini's UI), iterate over them until you find the network editor
  • inside the window screen estate get relative/offset positions for the client window using “ClientToScreen”, I think it's win32gui.ClientToScreen(clienthandle,(x,y))
)

If that's too academic, I'll have a peek at some old code and try to come up with a rudimentary “listing”!

Marc

EDIT: Sorry, this forum's editor screwed up my text, deleting and rearranging what I typed …
julien-b
Thanks Marc!

Unfortunately, I had to make it work in Linux. But I found a little trick :

networkEditor.setCursorPosition(hou.Vector2(0,0))
origin = QCursor.pos()

Basically putting the cursor at the origin of the networkEditor and retrieving the cursor position in Qt.
I had to do all sorts of conversions to get back on my feet, but it works

Cheers,

Julien
malbrecht
That's COOL! Slick idea :-)

Marc
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB