Creating screenshots for models

MakeHuman python API, python plugins, etc

Moderator: joepal

Creating screenshots for models

Postby MeditatingHamster » Mon Nov 09, 2020 11:11 am

Hi I'm currently trying to write a script that bulk converts my mhm models to fbx and creates a png file to go alongside them. What I have been able to cobble together so far works fine, except for the screen grabs in which the model seems zoomed out in the scene so I get a lot of empty space in the image. If I use setZoom(2) I get setZoom is not defined, which tells me this is not the way to use it. If someone could tell me how to zoom in before getting the screenshot it would be very appreciated. I'm ultimately just trying to create the equivalent of thumbnails to go alongside my FBX/mhm files. Thanks :-)

Code: Select all
import os
import mh
from core import G
mhapi = G.app.mhapi
human = mhapi.internals.getHuman()

directory = "C:\\Users\\userfolder\\Google Drive\\makehuman\\v1py3\\models"
for filename in os.listdir(directory):
    if filename.endswith(".mhm"):
        human.load("C:\\Users\\userfolder\\Google Drive\\makehuman\\v1py3\\models\\"+filename, True)
        mhapi.exports.exportAsFBX("C:\\Users\\userfolder\\Google Drive\\makehuman\\v1py3\\models\\"+filename[0:-4]+".fbx")
       
        mh.grabScreen(1, 1, G.windowWidth - 3, G.windowHeight - 3,"C:\\Users\\userfolder\\Google Drive\\makehuman\\v1py3\\models\\"+filename[0:-4]+".PNG")
    else:
        continue
MeditatingHamster
 
Posts: 5
Joined: Mon Nov 02, 2020 6:02 pm

Re: Creating screenshots for models

Postby MeditatingHamster » Tue Nov 10, 2020 11:24 am

My apologies, I was clearly having a slow moment yesterday as the parameter options seem obvious today.

mh.grabScreen(Xstartingpoint, Ystartingpoint, resolutionofwindowwidth,resolutionofwindowheight....)

On a 4k screen resolution these figures seem to work nicely.
mh.grabScreen(900, 200, G.windowWidth -1800, G.windowHeight -400,"C:\\Users\\userfolder\\Google Drive\\makehuman\\v1py3\\models\\"+filename[0:-4]+".PNG")
MeditatingHamster
 
Posts: 5
Joined: Mon Nov 02, 2020 6:02 pm


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron