Using of plugin/7_scripting as API

MakeHuman python API, python plugins, etc

Moderator: joepal

Using of plugin/7_scripting as API

Postby rajataggarwal91 » Fri Jun 26, 2015 1:48 am

Hi,
I read a lot about an API project being implemented, with pointers towards scripting.py under development. I can see that it works well using GUI in settings->scripting->execute tab. But when I try to model the same thing outside GUI, there are issues executing the same code, and understandably so. I am guessing I need to define correct objects, load them with object file data and the manipulate these using scripting.py functions. If we actually want to use scripting.py for our external applications, what objects should have been defined already?

What concerns me most is that "human" is a subclass of TaskView (if I am understanding it right). That means I would not be able to manipulate human without creating GUI objects. Is this true or I am just imagining things wrong.

Also I am confused about what selectedHuman attribute related to human is? Why do we require this?

Regards,
An enthusiast desperately trying to understand Makehuman code
rajataggarwal91
 
Posts: 11
Joined: Fri Jun 19, 2015 3:25 am

Re: Using of plugin/7_scripting as API

Postby joepal » Fri Jun 26, 2015 7:53 am

Yes, this is true, and a design choice. MH was never intended to be used as a library.

What scripting possibilities there are, are dependent on everything having been initialized. And this includes the GUI.

This said, there is an (unofficial and unmaintained) fork for running MH in command line mode:

https://bitbucket.org/MakeHuman/makehum ... dless/diff
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4469
Joined: Wed Jun 04, 2008 11:20 am

Re: Using of plugin/7_scripting as API

Postby duststorm » Tue Jun 30, 2015 7:40 am

Actually this is not true, the human can be manipulated without a need for gui elements. Human inherits from guicommon.Object which does not rely on any GUI modules.

The maintained version of the commandline fork is an example of this:
http://bugtracker.makehumancommunity.or ... ommandline
https://bitbucket.org/duststorm01/makehuman-commandline

app.selectedHuman is simply a pointer to the human object in use by the program.
You can grab it with the following imports:
Code: Select all
from core import G
app = G.app
human = app.selectedHuman


All the functions available in the scripting plugin are declared in the scripting plugin module, which is probably not the best design choice but it does keep everything together. Since the plugin module contains gui elements, importing it will drag in the gui dependencies automatically.
Anyway, open up the scripting plugin and have a look at the code, those functions could serve as inspiration.
MakeHuman™ developer
User avatar
duststorm
 
Posts: 2569
Joined: Fri Jan 27, 2012 11:57 am
Location: Belgium

Re: Using of plugin/7_scripting as API

Postby rajataggarwal91 » Wed Jul 01, 2015 11:43 pm

Thank you for your reply.
So if I were to create more functions for Scripting but without using GUI elements, how could I get human properly declared and initalized, so that I could apply functions like setAge() without using Scripting()
What I am looking for is Scripting without GUI elements and Makehuman working at all. I know there is commandline project, which works great, but instead of redundantly implementing modifiers using it, I wish to use MakeHuman modifiers.

I am still wondering if everything that MH works on is interpolation between targets. Where are we using geometry.py, transformation.py for?
How does the target file gets selected on the fly based on the present configuration? I am still searching for part of the code which does that.

It is a good idea to have every file's header documented with description about when the functions are being called and what they do. I would love to help out in documentation, will save a lot of questions we have to ask on forums.
rajataggarwal91
 
Posts: 11
Joined: Fri Jun 19, 2015 3:25 am


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron