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

Re: Creating screenshots for models

Postby cmpolik » Wed Dec 04, 2024 10:20 am

Hey brother,

I hope you’re doing well!

First of all, thanks for sharing the code for grabbing. I really appreciate it since I couldn’t find any documentation or datasheet about the mh module functions and their usage.

Could you please share any resources you have? Anything related to coding with the mh module—documentation, examples, or guides—would be super helpful.

Secondly, I tried using your code, but I keep getting an error saying there’s no mh module. I’ve tried various approaches, like placing the Python file in different MakeHuman folders (plugins, models, etc.), but the error persists.

From what I understand, the mh module is embedded within the MakeHuman interface. I even tried going to Settings → User Plugins, loading my Python code successfully, and activating the plugin, but nothing seems to change.

My goal is to automate taking screenshots of models because I have more than 400 .mhm files to process.

Could you advise me on what to do to resolve this issue and proceed with automation?

Thanks a ton in advance!
cmpolik
 
Posts: 1
Joined: Wed Dec 04, 2024 10:04 am


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest