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?

  • $\begingroup$ You can create a vertex group and then assign the new coordinates to them based on some criteria (for instance traversing from left to right and then down to identify which vertex the coordinate values are getting assigned). It will be easier for users to answer your question if you are more specific. Is it possible for you to share a sample blend file or part of it and the coordinates? $\endgroup$ – Blender Dadaist Oct 19 '18 at 8:43
  • $\begingroup$ Thank you first. The models I have is somehow credential by our regulations/privacy issues. Could you recommend an example code of assigning the coordinates to the vertex group? I think there must be some, but I have not found any answers after quite some searching work... $\endgroup$ – Ray Oct 19 '18 at 9:04

Nose size change

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')

    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)
| improve this answer | |
  • $\begingroup$ Thumb up for this fantastic answer! It offered much help and brought me on the track. $\endgroup$ – Ray Oct 30 '18 at 7:59
  • $\begingroup$ Glad that it was of use to you :) $\endgroup$ – Blender Dadaist Oct 30 '18 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.