Little help with first plugin

MakeHuman python API, python plugins, etc

Moderator: joepal

Little help with first plugin

Postby Nate8 » Sun Jan 31, 2016 10:17 pm

So far i'm working on my own little plugin and have already a category set up with some buttons and what i basically want for now is to decide via two radio buttons between full male or full female and also if the human is tall or short. If then a 'create' button is clicked I either get a tall male, short male, tall female or short female.
That's how I would like to have it, however I tried for some time now to get the 'create' button working but the whole human model does not change at all.
I already looked in the 7_example.py and 0_modeling_8_random.py for orientation but I still don't get it.
Nate8
 
Posts: 10
Joined: Wed Jan 27, 2016 6:19 pm

Re: Little help with first plugin

Postby joepal » Sun Jan 31, 2016 11:28 pm

Take a look in the scripting plugin, specifically the Scripting class a bit down in this file:

https://bitbucket.org/MakeHuman/makehum ... ew-default

This is unmaintained and might be outdated in some parts, but it should give you some tips on how to proceed.

This plugin should be included but probably disabled in the nightly builds.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4465
Joined: Wed Jun 04, 2008 11:20 am

Re: Little help with first plugin

Postby Nate8 » Tue Feb 02, 2016 12:47 am

I already saw that plugin before and to be honest I don't really know what good it is for me?
For example if i want to change the gender and i click one button i get a male human and click the other button i get a female human.
Nate8
 
Posts: 10
Joined: Wed Jan 27, 2016 6:19 pm

Re: Little help with first plugin

Postby joepal » Tue Feb 02, 2016 6:28 am

What is the problem here? That you don't know how to enable a click event on a button or that you don't know how to apply a macro target to the toon? Or that the character on the screen doesn't update despite you seemingly having done the right thing to it?
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4465
Joined: Wed Jun 04, 2008 11:20 am

Re: Little help with first plugin

Postby duststorm » Tue Feb 02, 2016 9:28 am

Try human.setGender, there's an example of it in the scripting plugin.
MakeHuman™ developer
User avatar
duststorm
 
Posts: 2569
Joined: Fri Jan 27, 2012 11:57 am
Location: Belgium

Re: Little help with first plugin

Postby Nate8 » Tue Feb 02, 2016 2:38 pm

First of all, thank you that you guys are trying to help me :)

joepal wrote: That you don't know how to enable a click event on a button or that you don't know how to apply a macro target to the toon?


The click events already work in a way that i'm able to change text. So if i click the button it says: You chose option 1, and if i select option 2 it says 'you chose option 2'. something like that.
but yeah, i think the problem seem to be the macro targets, i don't really know what they are and how they work or how i apply them to the button?!




duststorm wrote:Try human.setGender, there's an example of it in the scripting plugin.


hmm i don't seem to find anything
Nate8
 
Posts: 10
Joined: Wed Jan 27, 2016 6:19 pm

Re: Little help with first plugin

Postby joepal » Tue Feb 02, 2016 4:04 pm

It's called updateModelingParameter. The relevant lines are 637-642

Code: Select all
    def updateModelingParameter(self, parameterName, value):
        log.message("SCRIPT: updateModelingParameter(parameterName, value)")
        modifier = self.human.getModifier(parameterName)
        modifier.setValue(value)
        self.human.applyAllTargets()
        mh.redraw()


You need to bind a function event to your button, and in that function:

* find a modifier matching the name you want (for example "macrodetails/Gender")
* apply a value between 0.0 and 1.0 to it
* run applyAllTargets() (not sure if this is strictly necessary)
* run redraw

The approach is the same for a single target, with some minor variations. Then the relevant lines are 564 - 568.

If you need more detailed documentation on how to bind click events to buttons, see the PyQT documentation. This is not specific for makehuman.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4465
Joined: Wed Jun 04, 2008 11:20 am

Re: Little help with first plugin

Postby Nate8 » Wed Feb 03, 2016 3:57 pm

Alright thanks, it works now :) Thanks.

Now I see that there are many possible modifiers, for example "armslegs/l-upperarm-scale-horiz-decr|incr" which seem to go from 1.0 to -1.0. I wonder if it's also possible to give the model specific values, for example i want the human to be 185cm tall and give his upper arms and length of 50cm for example.
Nate8
 
Posts: 10
Joined: Wed Jan 27, 2016 6:19 pm

Re: Little help with first plugin

Postby duststorm » Wed Feb 03, 2016 4:09 pm

No, you'd have to write such a thing yourself.
Some inspiration can be gotten from the measurement plugin, but it's a brute force approach.
MakeHuman™ developer
User avatar
duststorm
 
Posts: 2569
Joined: Fri Jan 27, 2012 11:57 am
Location: Belgium

Re: Little help with first plugin

Postby badwolf » Wed Feb 03, 2016 4:25 pm

duststorm wrote:No, you'd have to write such a thing yourself.
Some inspiration can be gotten from the measurement plugin, but it's a brute force approach.



to give you an idea of what this will take Gender And Age both (and together) will change what a given modifier will mean.

so -0.75 in say upper arm length will mean different things for Male 12 Female 12 Male 20 Female 20


and i think that other items on the main tab will shift your marks.
badwolf
 
Posts: 272
Joined: Fri Feb 06, 2015 12:41 am

Next

Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest