how can I change the mesh in MakeHuman from script? For example, I want to change the geometry of the nose, given that I have the desired coordinates values of the nose vertices, how can I assign these values to vertices by loading from a file or scripting?
Here is a small script that grows or shrinks the nose by changing the z coordinates of the vertices defined in the vertex group 'nose' (please refer the gif above). If you have the new coordinates with you, you need to have some criterion to determine which coordinate is to be applied to which one in the group. For instance you can sort the
vertIdxs based on coordinates (cf. the commented line sorting the vertices by y, x and z). If you have that criterion, you can simply assign the new coordinate values in a loop as done in the sample code.
import bpy def changeSize(by): for idx in vertIdxs: obj.data.vertices[idx].co.z += by vertGrpName = 'nose' obj = bpy.context.object if(obj.vertex_groups.get(vertGrpName) == None): print('Please create a vertex group with the name', vertGrpName, 'for nose vertices') else: vertIdxs = [v.index for v in obj.data.vertices if (obj.vertex_groups[vertGrpName].index in [g.group for g in v.groups])] #vertIdxs = sorted(vertIdxs, key = lambda x: (obj.data.vertices[x].co.y, obj.data.vertices[x].co.x, obj.data.vertices[x].co.z)) changeSize(by = 0.05) #changeSize(by = -0.05)