[QUESTION] Screenshot through maya batch

python
maya

#1

Hello guys,

I have been trying to take a screenshot of fbx through maya batch or line render, but so far I can only do inside of maya.
Do you guys have any idea how to do this?

Cheers and thank you all!


#2

Hey julienangel,

Have you tried the standalone Maya or Headless Maya stuff?

Or am I missing the point?


#3

Hey man, thank you so much for replying.

I am trying with standalone maya, and I am trying render with maya software, but so far, I couldnt do something good :frowning:

Cheers


#4

Hey julienangel!

You need to render (not playblast) with “Maya Hardware 2.0” in Maya standalone. “Maya Hardware 2.0” is the “normal” viewport renderer and should give you the same results as you see when you open the file Maya. “Maya Software” is hopelessly out dated.
Also make sure that the machine that you are doing this on has a graphic card. “Hardware 2.0” needs it.

I don’t have time right now to give you the exact lines of code, but I hope this brings you in the right direction.

Cheers


#5

Hey there, Thank you!

My problem is being , when I create a scene with maya standalone, import fbx, and save the scene, the problem is, with maya standalone, I cant make view fit in the object, to make the object in a cool scale to the camera.

Any idea to solve this part?

Cheers


#6

Hmmm tricky. This will always be some sort of guess operation. You can calculate a “view fit” yourself but that’s not trivial. You could do some simple calculation where you set the distance of the camera based on the bounding box of the objects. Depending on your time frame this might or night not be a good idea.
Or just render the “persp” camera and hope for the best :wink: .


#7

I will try, thank you so much! :smiley:


#8

Just ripping from the Maya docs for the viewFit Fasbue mentioned:

import maya.cmds as cmds

# Position the active camera to view the active objects
cmds.viewFit()

# Position cameraShape-1 to view all objects
cmds.viewFit( 'cameraShape1', all=True )

# Fill 50 percent of the active view with active objects
cmds.viewFit( f=0.5 )

cmds.viewFit( all=True )

#9

Hey RiggerRyan!

The viewFit command unfortunately needs the Maya GUI and is not available in Maya Standalone. It’s one of the typical Maya oddities. :roll_eyes:


#10

Yeah I see what you mean :confused:

Another option is to open Maya via the commandline, run the scripts you need and close Maya again (if you want it to be closed afterwards). Not prettiest way, but it could do the trick.