How to use proxies to implement python code

MakeHuman python API, python plugins, etc

Moderator: joepal

How to use proxies to implement python code

Postby tomtom92 » Mon Apr 08, 2019 10:41 am

Hi guys.
I'm new in this forum and i need some help. I'm writing Phyton code to create models using MH as a library without graphic interface from linux bash. Using MH source code i wrote some code to run MH in background and it works, wrote a script to enter macro values and it works. In output from that code i have one or more fbx models that i can export in Blender, and a report file with all the values ​​of the macros used ( gender, age, %muscle, weight, height, body proportion, breast size, breast firmness and ethnicity ).
My problem is that: i need to add hair, clothes, skeleton and rig the model using the proxies from source code. I cannot understand how these proxies works because they are written differently than macros.
If someone will be able to help me I would be very grateful because I can't go on with my work.
Thanks.
tomtom92
 
Posts: 4
Joined: Fri Apr 05, 2019 10:49 am

Re: How to use proxies to implement python code

Postby Aranuvir » Mon Apr 08, 2019 11:46 am

Joel has been working on that stuff and has created a convenience library called mhapi: https://github.com/makehumancommunity/c ... gins-mhapi. Perhaps you can find the answer in the docs.

BTW, if you know coding and want to support the project, fixes are always welcome. For example, the fbx exporter has problems with the skeletons. Any help here would be appreciated... :D
Aranuvir
 
Posts: 1314
Joined: Sun Oct 12, 2014 2:12 pm

Re: How to use proxies to implement python code

Postby tomtom92 » Mon Apr 08, 2019 12:28 pm

Aranuvir wrote:Joel has been working on that stuff and has created a convenience library called mhapi: https://github.com/makehumancommunity/c ... gins-mhapi. Perhaps you can find the answer in the docs.

BTW, if you know coding and want to support the project, fixes are always welcome. For example, the fbx exporter has problems with the skeletons. Any help here would be appreciated... :D


Thanks for the tip, i will check that. :D
I'm working on this for an internship for my university, trying to develop it and use as a thesis for graduation. If I can develop a well working product I will be happy share it.
tomtom92
 
Posts: 4
Joined: Fri Apr 05, 2019 10:49 am

Re: How to use proxies to implement python code

Postby Aranuvir » Mon Apr 08, 2019 1:04 pm

Good luck with your thesis!

You'll probably encounter bugs, you need to fix. Maybe you want to provide them. Best practice for that task: fork on github and make pull requests...
Aranuvir
 
Posts: 1314
Joined: Sun Oct 12, 2014 2:12 pm

Re: How to use proxies to implement python code

Postby joepal » Fri Apr 12, 2019 4:19 pm

You could take a look at line 595 here: https://github.com/makehumancommunity/c ... _assets.py

Possibly you'll run into problems since I'm using TaskView code to equip proxies, but I'm not sure you have those when running headless.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4455
Joined: Wed Jun 04, 2008 11:20 am

Re: How to use proxies to implement python code

Postby tomtom92 » Mon Apr 15, 2019 2:20 pm

Thanks i will check that.
Last edited by tomtom92 on Mon Apr 15, 2019 2:44 pm, edited 1 time in total.
tomtom92
 
Posts: 4
Joined: Fri Apr 05, 2019 10:49 am

Re: How to use proxies to implement python code

Postby tomtom92 » Mon Apr 15, 2019 2:28 pm

joepal wrote:You could take a look at line 595 here: https://github.com/makehumancommunity/c ... _assets.py

Possibly you'll run into problems since I'm using TaskView code to equip proxies, but I'm not sure you have those when running headless.


Thanks for the tip. I looked at it but did not work with my code. I found another way to add what i need using official libraries.
Code: Select all
                                                print(shoes)
                                                print(mhclofile)
                                                pxy = proxy.loadProxy(human, mhclofile, type='Shoes')
                                                mesh,obj = pxy.loadMeshAndObject(human)
                                                mesh.setPickable(True)
                                                gui3d.app.addObject(obj)
                                                mesh2 = obj.getSeedMesh()
                                                fit_to_posed = True
                                                pxy.update(mesh2, fit_to_posed)
                                                mesh2.update()
                                                obj.setSubdivided(human.isSubdivided())
                                                human.addClothesProxy(pxy)
                                                vertsMask = np.ones(human.meshData.getVertexCount(), dtype=bool)
                                                proxyVertMask = proxy.transferVertexMaskToProxy(vertsMask, pxy)
                                                #Apply accumulated mask from previous clothes layers on this clothing piece
                                                obj.changeVertexMask(proxyVertMask)
                                                if pxy.deleteVerts is not None and len(pxy.deleteVerts > 0):
                                                    log.debug("Loaded %s deleted verts (%s faces) from %s proxy.", np.count_nonzero(pxy.deleteVerts), len(human.meshData.getFacesForVertices(np.argwhere(pxy.deleteVerts)[...,0])),pxy.name)
                                                # Modify accumulated (basemesh) verts mask
                                                verts = np.argwhere(pxy.deleteVerts)[...,0]
                                                vertsMask[verts] = False
                                                human.changeVertexMask(vertsMask)
                                                event = events3d.HumanEvent(human, 'proxy')
                                                event.pxy = 'shoes'
                                                human.callEvent('onChanged', event)


Now the only thing I miss is to add the skeleton to the model. I don't think that modifying this code will also work for the skeleton.
tomtom92
 
Posts: 4
Joined: Fri Apr 05, 2019 10:49 am

Re: How to use proxies to implement python code

Postby Faustoryld » Wed May 19, 2021 2:49 pm

Hi, I'm also new to this forum, and I didn't even know until this moment that it was possible to use a proxy for python. This is very interesting, of course. The more you read the information on this site, the more you know. I'm just now setting up a proxy server for Firebox myself and experiencing some difficulties with this. Mainly, I can't do anything with setting up the router. No matter how many guides I read, almost nothing helps. Recently, a friend suggested to me one site, through which I am now trying to make the proxy work.
User avatar
Faustoryld
 
Posts: 1
Joined: Wed May 19, 2021 2:47 pm


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest