Newer
Older
for (key, val, sub) in tokens:
defaultKey(key, val, sub, "data", exclude, globals(), locals())
typeSplit = str(type(data)).split("'")
if typeSplit[0] != '<class ':
return None
classSplit = typeSplit[1].split(".")
if classSplit[0] == 'bpy' and classSplit[1] == 'types':
return classSplit[2]
elif classSplit[0] == 'bpy_types':
return classSplit[1]
else:
return None
if string == 'True':
return True
elif string == 'False':
return False
else:
raise NameError("Bool %s?" % string)
global rigLeg, rigArm, toggle
res = eval(condition, globals())
try:
res = eval(condition, globals())
#print("%s = %s" % (condition, res))
return not res
except:
#print("%s invalid!" % condition)
return True
#
# clearScene(context):
# hideLayers():
#
global toggle
scn = bpy.context.scene
for n in range(len(scn.layers)):
scn.layers[n] = True
print("clearScene %s %s" % (toggle & T_Replace, scn))
if not toggle & T_Replace:
return scn
for ob in scn.objects:
if ob.type == "MESH" or ob.type == "ARMATURE":
scn.objects.active = ob
bpy.ops.object.mode_set(mode='OBJECT')
scn.objects.unlink(ob)
del ob
#print(scn.objects)
return scn
scn = bpy.context.scene
for n in range(len(scn.layers)):
if n < 3:
scn.layers[n] = True
else:
scn.layers[n] = False
return
#
DEBUG= False
from bpy.props import *
class IMPORT_OT_makehuman_mhx(bpy.types.Operator):
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
'''Import from MHX file format (.mhx)'''
bl_idname = "import_scene.makehuman_mhx"
bl_description = 'Import from MHX file format (.mhx)'
bl_label = "Import MHX"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
filepath = StringProperty(name="File Path", description="Filepath used for importing the MHX file", maxlen= 1024, default= "")
#preset = BoolProperty(name="Use rig preset", description="Use rig preset (Classic/Gobo)?", default=True)
#presetRig = EnumProperty(name="Rig", description="Choose preset rig",
# items = [('Classic','Classic','Classic'), ('Gobo','Gobo','Gobo')], default = '1')
footRig = EnumProperty(name="Foot rig", description="Foot rig",
items = [('Reverse foot','Reverse foot','Reverse foot'), ('Gobo','Gobo','Gobo')], default = '1')
fingerRig = EnumProperty(name="Finger rig", description="Finger rig",
items = [('Panel','Panel','Panel'), ('Curl','Curl','Curl'), ('IK','IK','IK')], default = '1')
mesh = BoolProperty(name="Mesh", description="Use main mesh", default=toggle&T_Mesh)
armature = BoolProperty(name="Armature", description="Use armature", default=toggle&T_Armature)
proxy = BoolProperty(name="Proxy", description="Use proxy object", default=toggle&T_Proxy)
replace = BoolProperty(name="Replace scene", description="Replace scene", default=toggle&T_Replace)
face = BoolProperty(name="Face shapes", description="Include facial shapekeys", default=toggle&T_Face)
shape = BoolProperty(name="Body shapes", description="Include body shapekeys", default=toggle&T_Shape)
symm = BoolProperty(name="Symmetric shapes", description="Keep shapekeys symmetric", default=toggle&T_Symm)
def execute(self, context):
global toggle
Thomas Dinges
committed
O_Mesh = T_Mesh if self.mesh else 0
O_Armature = T_Armature if self.armature else 0
O_Proxy = T_Proxy if self.proxy else 0
O_Replace = T_Replace if self.replace else 0
O_Face = T_Face if self.face else 0
O_Shape = T_Shape if self.shape else 0
O_Symm = T_Symm if self.symm else 0
#O_Preset = T_Preset if self.preset else 0
toggle = O_Mesh | O_Armature | O_Proxy | T_ArmIK | T_LegIK | O_Replace | O_Face | O_Shape | O_Symm | T_MHX
Thomas Dinges
committed
readMhxFile(self.filepath,
(self.footRig,
self.fingerRig))
return {'FINISHED'}
def invoke(self, context, event):
wm.add_fileselect(self)
return {'RUNNING_MODAL'}
'''
class MakeHumanFKIKPanel(bpy.types.Panel):
bl_label = "MakeHuman FK/IK"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
def draw(self, context):
layout = self.layout
ob = bpy.context.active_object
if ob.type == 'ARMATURE':
layout.row().prop(ob, "PArmIK_L")
layout.row().prop(ob, "PArmIK_R")
layout.row().prop(ob, "PLegIK_L")
layout.row().prop(ob, "PLegIK_R")
layout.row().prop(ob, "PHandLocal_L")
layout.row().prop(ob, "PHandLocal_R")
layout.row().prop(ob, "PFootLocal_L")
layout.row().prop(ob, "PFootLocal_R")
return
bl_label = "MakeHuman Fingers"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
def draw(self, context):
layout = self.layout
pb = bpy.context.active_pose_bone
layout.row().prop(pb, "MHRelax")
layout.row().prop(pb, "MHCurl")
layout.row().prop(pb, "MHCone")
layout.row().prop(pb, "MHSpread")
layout.row().prop(pb, "MHScrunch")
layout.row().prop(pb, "MHLean")
return
Thomas Dinges
committed
bpy.types.Object.PArmIK_L = FloatProperty(name="L arm - IK", default = 0, min = 0.0, max = 1.0)
bpy.types.Object.PArmIK_R = FloatProperty(name="R arm - IK", default = 0, min = 0.0, max = 1.0)
bpy.types.Object.PLegIK_L = FloatProperty(name="L leg - IK", default = 0, min = 0.0, max = 1.0)
bpy.types.Object.PLegIK_R = FloatProperty(name="R leg - IK", default = 0, min = 0.0, max = 1.0)
bpy.types.Object.PHandLocal_L = FloatProperty(name="L hand - Loc", default = 0, min = 0.0, max = 1.0)
bpy.types.Object.PHandLocal_R = FloatProperty(name="R hand - Loc", default = 0, min = 0.0, max = 1.0)
bpy.types.Object.PFootLocal_L = FloatProperty(name="L foot - Loc", default = 0, min = 0.0, max = 1.0)
bpy.types.Object.PFootLocal_R = FloatProperty(name="R foot - Loc", default = 0, min = 0.0, max = 1.0)
bpy.types.PoseBone.MHCone = FloatProperty(name="Cone", default = 0, min = -0.5, max = 1.0)
bpy.types.PoseBone.MHRelax = FloatProperty(name="Relax", default = 0, min = -0.5, max = 1.0)
bpy.types.PoseBone.MHCurl = FloatProperty(name="Curl", default = 0, min = -0.5, max = 1.0)
bpy.types.PoseBone.MHLean = FloatProperty(name="Lean", default = 0, min = -1.0, max = 1.0)
bpy.types.PoseBone.MHScrunch = FloatProperty(name="Scrunch", default = 0, min = -0.5, max = 1.0)
bpy.types.PoseBone.MHSpread = FloatProperty(name="Spread", default = 0, min = -0.5, max = 1.0)
bpy.types.register(MakeHumanFKIKPanel)
bpy.types.register(MakeHumanFingerPanel)
bpy.types.unregister(MakeHumanFKIKPanel)
bpy.types.unregister(MakeHumanFingerPanel)
'''
def menu_func(self, context):
self.layout.operator(IMPORT_OT_makehuman_mhx.bl_idname, text="MakeHuman (.mhx)...")
#
"""
theScale = 1.0
toggle = T_Replace + T_Mesh + T_Armature + T_MHX + T_ArmIK + T_LegIK
#rigLeg = T_Toes + T_GoboFoot
#rigArm = T_ElbowPT + T_FingerCurl
#readMhxFile("/home/thomas/makehuman/exports/foo-25.mhx")
#toggle = T_Replace + T_Armature
#readMhxFile("/home/thomas/makehuman/exports/foo-sintel-25.mhx")
readMhxFile("C:/Documents and Settings/xxxxxxxxxxxxxxxxxxxx/Mina dokument/makehuman/exports/foo-25.mhx", 'Classic')
#readMhxFile("/home/thomas/mhx5/test1.mhx")
#readMhxFile("/home/thomas/myblends/gobo/gobo.mhx")
#readMhxFile("/home/thomas/myblends/sintel/simple.mhx")
"""