Isotropix Forums

[3d View] Write screenshots

Clarisse Scripting related topics

[3d View] Write screenshots

Unread postby cchampet » Fri Oct 06, 2017 11:12 am

Hello,

I'm looking for a solution to automatically write screenshots of the current 3d view of a Clarisse scene.
I am used to use cmds.modelEditor and cmds.playblast in Maya to update the 3d view (shading, wireframe, normal...) and write images on disk.

Do you have the same type of tools in your API? If not, maybe I can use pyqt features, but I need to have access to the widget that corresponds to the 3d view. How can I do that?

I'm using Clarisse-3.0 on Linux.

Thank you for your time.
Cheers,
Clement
cchampet
 
Posts: 12
Joined: Fri May 19, 2017 9:20 am

Re: [3d View] Write screenshots

Unread postby bvaldes » Fri Oct 06, 2017 2:47 pm

Hi,

For now, this is not possible to take a screenshot from the 3dview. The widgets are not exposed in python, moreover, you can grab some information about the widget that gets the focus:

python code

focusedWidget = ix.api.GuiWidget.get_focused_widget()
print "width:", focusedWidget.get_width()
print "height:", focusedWidget.get_height()


You won't be able to test this code by running it from the script editor, you have to use it from the shelf. Else the focus will be taken by the script editor.

Regards
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 153
Joined: Mon Sep 26, 2016 11:44 am

Re: [3d View] Write screenshots

Unread postby cchampet » Mon Oct 09, 2017 5:31 pm

Thank you for your feedback Benoit.

I have found a basic solution using PyQt features. I post it here, even if there is nothing specific to Clarisse ; hope this will help someone.

Code: Select all
from Qt import QtGui
import os
import ix

# Take a screenshot for each screen
screenshotExt = 'jpg'
desktop = ix.app.desktop()
for screenIndex in range(0, desktop.screenCount()):
    geo = desktop.screenGeometry(screenIndex)
    grabWindow = QtGui.QPixmap.grabWindow(desktop.winId(), geo.left(), geo.top(), geo.width(), geo.height())

    screenshotPath = os.path.join('/tmp', os.path.basename(ix.application.get_current_project_filename()) + '_' + str(screenIndex) + '.' + screenshotExt)
    screenshotTook = grabWindow.save(screenshotPath, screenshotExt)


Cheers,
cchampet
 
Posts: 12
Joined: Fri May 19, 2017 9:20 am

Re: [3d View] Write screenshots

Unread postby bvaldes » Tue Oct 10, 2017 1:37 pm

Hi,

Thanks for the script, I am sure that it will help someone to make nice tools (Why not a nice asset manager plugin :))

Cheers
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 153
Joined: Mon Sep 26, 2016 11:44 am


Return to Scripting