resizing background with script

MakeHuman python API, python plugins, etc

Moderator: joepal

resizing background with script

Postby Shreyansh_Dubey » Thu Sep 27, 2018 7:24 am

How can I edit 0_modelling_background.py so that I am able to resize the background image with respect to the height of my humanoid object.
Or my work can also be done if I am able to set a maximum background image size, actually when I grab the model I want to convert the screenshot in a perfect binary image of the humanoid model so i was setting a white background to it. I am able to resize the backgroud manually by holding shift+rightclick+mouse but all the work of designing the model I am doing with script so I can't do it manually for every model that I make before taking the screenshot I just want a way through which I can either set a maximum sized background image possible for all models(such that all my models fit into that white background), or my background should adjust its size automatically with the height of model. In all I just want a perfect white background for every model that I take before I take a screenshot, and this should happen through script only.

Please anyone help me. :geek:
Shreyansh_Dubey
 
Posts: 9
Joined: Sun Sep 16, 2018 10:09 am

Re: resizing background with script

Postby Shreyansh_Dubey » Thu Sep 27, 2018 9:44 am

I found that thing we will have to edit 0_modelling_background.py in line 425(in my sys), actually it is in this
[ def setBackgroundScale(self, scale):
if not self.isBackgroundShowing():
return
side = self.getCurrentSide()
scale = abs(float(scale))
(_, aspect) = self.getCurrentBackground()
self.backgroundImage.mesh.resize(scale * 50.0 * aspect, scale * 50.0) ## changed here both places from 20 to 50 to apply maximum background size
self.transformations[side][1] = scale
]

And now the background will appear to remain unchanged even after increasing height as we have increased the aspect and scaling.
Shreyansh_Dubey
 
Posts: 9
Joined: Sun Sep 16, 2018 10:09 am

Re: resizing background with script

Postby Aranuvir » Thu Sep 27, 2018 7:53 pm

Code: Select all
from core import G

sides = { 'front': [0,0,0],
             'back': [0,180,0],
             'left': [0,-90,0],
             'right': [0,90,0],
             'top': [90,0,0],
             'bottom': [-90,0,0]}

category = G.app.getCategory('Settings')
task = category.getTaskByName('Background')
G.app.axisView(sides.get(<MySideName>, [0,0,0]))
task.setBackgroundScale(<MyFloatVal>)


I don't thinks there is another way to access background data...
Aranuvir
 
Posts: 1314
Joined: Sun Oct 12, 2014 2:12 pm


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest