makehuman into blender tutorial

If you have problems understanding something or getting started, ask here

Moderator: joepal

Script to rename bones symmetrically

Postby m.e » Wed Jul 30, 2008 9:02 am

While I am at it, here is another script I have written which renames the bones symmetrically. Officially no connection to makehuman, but makehuman creates bones with uninformative names (joint0, joint1,...) that are not symmetrical. This script gives the bones uninformative names that are symmetrical so that flip-pose and the like work in blender. You want to run this script before you attach the armature to the mesh, so that the auto vertex groups have the new names.
Code: Select all
#!BPY

# """
# Name: 'Rename Bones'
# Blender: 246
# Group: 'Armature'
# Tooltip: 'Rename bones so that they are symmetrical.'
# """

import Blender
from Blender import Window, Draw, Scene, Object, Mesh

__author__ = 'Martin Ellison'
__version__ = '1.0 2008/07/30'
__url__ = []
__email__ = ["Martin Ellison, m.e:acm*org", "scripts"]
__bpydoc__ = """\
1. Make sure the armature is aligned so that +X is left and -X is right.
2. Select the armature.
3. Run this script.
Bones will all have new names with matching left and right bone names.
Note: there must be only one bone without a parent for this to work.
 """

# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Martin Ellison
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender
from Blender import Armature, Scene, Draw, Mathutils
from Blender.Mathutils import *

index = 0
boneChildren = {}
eps = 0.01

def pair(arm_data, left, right):
   boneLeft = arm_data.bones[left]
   boneRight = arm_data.bones[right]   
   global index
   leftChildCount = len(boneChildren[left])
   rightChildCount = len(boneChildren[right])
   if leftChildCount == rightChildCount:
      for i in range(leftChildCount):
         pair(arm_data, boneChildren[left][i], boneChildren[right][i])
   else:
      print 'unmatched pair %s %s' % (left, right)
   index += 1
   arm_data.bones[left].name = 'mybone' + str(index) + '_R'
   arm_data.bones[right].name = 'mybone' + str(index) + '_L'
   
def fix(arm_data, boneParentName):
   boneParent = arm_data.bones[boneParentName]
   boneParent.head[0] = 0
   boneParent.tail[0] = 0
   global index
   offChildren = []
   for boneName in boneChildren[boneParentName]:
      bone = arm_data.bones[boneName]
      if abs(bone.head[0]) > eps:
         offChildren.append(boneName)
   if len(offChildren) == 2:
      if arm_data.bones[offChildren[0]].head[0] < 0:
         pair(arm_data, offChildren[0], offChildren[0])
      else:         
         pair(arm_data, offChildren[1], offChildren[0])
   for boneName in boneChildren[boneParentName]:
      if len(offChildren) != 2 or (boneName != offChildren[0] and boneName != offChildren[1]):
         bone = arm_data.bones[boneName]
         index += 1
         bone.name = 'mybone' + str(index)
         fix(arm_data, boneName)
         
def renameBones(arm_data):
   base = ''
   for bone in arm_data.bones.values():
      boneChildren[bone.name] = []
      for child in bone.children:
         boneChildren[bone.name].append(child.name)
      if not bone.hasParent():
         if base == '':
            base = bone.name
         else:
            Draw.PupMenu('more than one basis bone (%s, %s)' % (base, bone.name))
            return

   arm_data.makeEditable()
   fix(arm_data, base)   
   arm_data.update()
   
def main():
   scn= Scene.GetCurrent()
   arm_ob= scn.objects.active
   if not arm_ob or arm_ob.type != 'Armature':
                          Draw.PupMenu('you need to select an armature object')
                          return
        editmode = Window.EditMode()   
        if editmode: Window.EditMode(0)   
        Window.WaitCursor(1) 
        arm_data = arm_ob.getData()
        renameBones(arm_data)
        if editmode: Window.EditMode(1)
        Window.WaitCursor(0)
        Window.RedrawAll()

if __name__ == '__main__':
   main()         
m.e
 
Posts: 56
Joined: Wed Jul 23, 2008 9:20 am
Location: Shenzhen/Hong Kong

Re: makehuman into blender tutorial

Postby Tindytim » Thu Jul 31, 2008 3:23 am

andyp wrote:also @tindytim, you have been trying to use a custom head with your characters, i suggest that you first try rigging the regular charaters before you start modifying them, other wise you will get odd rigging issues


Not for the rigging. I've been using the Default Model since I started having issues. I may just install Ubuntu and see if that works, or if there is something wrong with my MakeHuman installation.
Tindytim
 
Posts: 11
Joined: Sun Jul 20, 2008 4:33 am

Re: makehuman into blender tutorial

Postby vigil » Mon Aug 04, 2008 12:41 am

Thanks andy for the tut and m.e for the scripts! I'm going to test the scripts soon, but should I rename the bones before using your bone heat fix? Also does the bone heat fix script complete the second part of the tutorial?
vigil
 
Posts: 4
Joined: Wed Jul 16, 2008 1:20 am

Re: makehuman into blender tutorial

Postby Anqueetus » Fri Aug 08, 2008 7:50 pm

Monstrous noob-a-saurus here, but I'm hoping to join the community here very soon. Anywho, I have a python/Blender/Makehuman/Collada/dumby McDumb Dumb issue. We will start with the fact I am working off of Windows...more specifically the beloved XP home edition. I downloaded Blender, downloaded Truespace 7.6, downloaded Makehuman, downloaded the current Python 2.5.2, downloaded the Blender plugin for Collada, downloaded some music for me, and built some shiney happy people in Makehuman. Now I have exported the models in .dae form successfully from Makehuman. I boot up the mythical Blender and click on file --> Import --> Collada 1.4, only to be greeted by, "CANNOT FIND FOLDER: Please set path in file 'colladaImport14.py'" Sweet Odin's Ravins!!!!

So I do what the previous fellow does and uninstall and reinstall Blender. No good. So then I Copy and past my mesh.dae file into the Blender folder...no go. Then I download the current Python to see if it is a scripting error. I shortly realize later that I'm a noobasaurus and begin to cry when I can't figure out python. So I download the current Collada plugin for Blender and hope the Blender understands my intentions. When I get the same message again, I begin to cry and tell the computer where the folder is. I then realize that my computer doesn't understand speech, so I copy and paste the Collada file into the Blender script folder found in the .blend folder. I then rub my hands manicly and try to import again. No cigar. So if anyone can tell me why Blender doesn't want my shiny happy people to hold hands....that would be great.

Anyone with the intention of helping me should understand that I have the computing powers of a very small monkey. Short from flinging my own poo, I have figured somethings out. I would, however, like to request from the most Noble and dare I say possibly sexy person that wants to help me that if they are going to type computer stuff to me, do so in the manner as though you had been soundly struck in the face with a shovel after drinking twenty nine bottles of mai-tais, and were trying to explain it to a small monkey. I think I should understand that. Or at the very least give me the special-ed version.

Well thanks again for the help my jiggedy g-funk chilley cheese dog home skillet brew slice. Peace, I'm outee.

NINJA, VANISH!!!!!
Anqueetus
 
Posts: 5
Joined: Fri Aug 08, 2008 7:30 pm

Re: makehuman into blender tutorial

Postby Anqueetus » Fri Aug 08, 2008 8:40 pm

Wow, so here's the level of dumbiness I have reached. I took the whole folder for Collada and placed it into the scripts folder of blender....guess who decided to work... Yes I am my own hero...no I don't sign autographs.
Anqueetus
 
Posts: 5
Joined: Fri Aug 08, 2008 7:30 pm

Re: makehuman into blender tutorial

Postby Jeremy Ray » Thu Aug 21, 2008 8:35 pm

m.e the bone weight fix script worked for me. Thanks!
Jeremy Ray
 
Posts: 17
Joined: Mon Feb 18, 2008 6:41 am

Re: makehuman into blender tutorial

Postby GrimJack » Sun Sep 07, 2008 3:55 am

Hi. I'm trying to run m.e's script that incorporates the first part of the tutorial, and I get the following message on my console:

-----
fixing mesh...
Traceback (most recent call last):
File "<string>", line 133, in <module>
File "<string>", line 122, in main
File "<string>", line 66, in fix_human
File "<string>", line 51, in add_texture
IOError: couldn't load image



I'm running Ubuntu Linux on a 1.7 MhZ Intel Celeron system with 2 gigs of RAM and a 128 MB Nvidia card.
GrimJack
 
Posts: 1
Joined: Sun Sep 07, 2008 3:50 am

Previous

Return to Newbies

Who is online

Users browsing this forum: No registered users and 1 guest