Page 1 of 1

How to use proxies to implement python code

PostPosted: Mon Apr 08, 2019 10:41 am
by tomtom92
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.

Re: How to use proxies to implement python code

PostPosted: Mon Apr 08, 2019 11:46 am
by Aranuvir
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

Re: How to use proxies to implement python code

PostPosted: Mon Apr 08, 2019 12:28 pm
by tomtom92
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.

Re: How to use proxies to implement python code

PostPosted: Mon Apr 08, 2019 1:04 pm
by Aranuvir
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...

Re: How to use proxies to implement python code

PostPosted: Fri Apr 12, 2019 4:19 pm
by joepal
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.

Re: How to use proxies to implement python code

PostPosted: Mon Apr 15, 2019 2:20 pm
by tomtom92
Thanks i will check that.

Re: How to use proxies to implement python code

PostPosted: Mon Apr 15, 2019 2:28 pm
by tomtom92
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.

Re: How to use proxies to implement python code

PostPosted: Wed May 19, 2021 2:49 pm
by Faustoryld
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.