Change Clothes via Script

MakeHuman python API, python plugins, etc

Moderator: joepal

Change Clothes via Script

Postby DarkAeon54 » Thu Mar 23, 2017 10:03 am

Does anyone know the python to change the clothes (Geometries>Clothes>Clothes)? I want to randomize and export humans with clothes so I need a script that can change this property.
Posts: 1
Joined: Thu Mar 23, 2017 10:00 am

Re: Change Clothes via Script

Postby markchang » Wed Jun 07, 2017 8:41 am

import proxy
import numpy as np
import events3d
human =
mhclofile = u'data/clothes/male_casualsuit01/male_casualsuit01.mhpxy'
pxy = proxy.loadProxy(human, mhclofile, type='Clothes')
mesh,obj = pxy.loadMeshAndObject(human)
mesh2 = obj.getSeedMesh()
fit_to_posed = False
pxy.update(mesh2, fit_to_posed)
vertsMask = np.ones(human.meshData.getVertexCount(), dtype=bool)
proxyVertMask = proxy.transferVertexMaskToProxy(vertsMask, pxy)
# Apply accumulated mask from previous clothes layers on this clothing piece
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])),
# Modify accumulated (basemesh) verts mask
verts = np.argwhere(pxy.deleteVerts)[...,0]
vertsMask[verts] = False
event = events3d.HumanEvent(human, 'proxy')
event.pxy = 'clothes'
human.callEvent('onChanged', event)
Posts: 1
Joined: Wed Jun 07, 2017 8:40 am

Re: Change Clothes via Script

Postby mlang » Wed Aug 09, 2017 9:20 am

this works great, unfortunately removing the added clothes doesn't.

Code: Select all
removes the proxy from the
Code: Select all
property, the clothes don't get removed from the human though.
Posts: 4
Joined: Tue May 23, 2017 2:51 pm

Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest