edit: the fix is further down
(I have an ugly hack to do this manually with IDLE.
the interesting part would be the next post)
problem: OBJ import loses set membership list. (for vertex groups)
the task:
assign the set membership of verts (maya) to blender vertex groups.
-take a piece of MEL code that selects a set of vertices and convert it to a piece of blender python that can be run from the text editor in Blender, so the resultant selected verts can be assigned to a vertex group - optionally, automate the assignment to vertex group(s).
OBJ vertex numbering begins at 1.
maya and blender both begin at 0.
Here’s what you get in maya when you select a set, then when you drag select the membership :
select -r -ne L_elbowSet ; // this is the set
select -r rabbit.vtx[9] rabbit.vtx[10] rabbit.vtx[11] rabbit.vtx[12] rabbit.vtx[21] rabbit.vtx[22] rabbit.vtx[23] rabbit.vtx[24] rabbit.vtx[33] rabbit.vtx[34] rabbit.vtx[36] rabbit.vtx[67] rabbit.vtx[68] rabbit.vtx[69] rabbit.vtx[80] rabbit.vtx[81] rabbit.vtx[82] rabbit.vtx[86] rabbit.vtx[87] rabbit.vtx[90] rabbit.vtx[91] rabbit.vtx[92] ;
- a utility to take the above list of verts and put it in a form blender will be able to use to select the verts. Preferably reads a file and saves to a new file, and runs from IDLE.
- a script to run from inside blender to select a list of verts (so I can manually create a vertex group and assign the selection to it)
optional script to create the vertex group based on the set name; add the selected verts to the group.
in blender, I need:
? will the verts be same numbered ? // we can hope.
to work the mesh … (find how it is refered in blender)
probably have to be in edit mode
create vertex groups for the mesh
name ‘L_elbowSet’ // could be set1, etc… for all I care. They will get renamed again before I am done.
add each vert to the selection // the important part
assign the selection to the vertex group
what would be the script to select a vert based on it’s index?
add (or append) a vert to a selection?
pseudo code:
need clever name for script v1.0
extract list of values from MEL data, save to file
import Blender
replace = Blender.Mesh.AssignModes.REPLACE
mesh = rabbit.getData(mesh=True)
mesh.addVertGroup(‘renameMe’)
read the data and put it into a list
vertList = [] # list of integers
mesh.assignVertsToGroup(‘renameMe’, vertList, 1.0, replace)