Newer
Older
for (key, val, sub) in tokens:
if key == 'Modifier':
parseModifier(ob, val, sub)
elif key == 'Constraint':
parseConstraint(ob.constraints, None, val, sub)
elif key == 'AnimationData':
parseAnimationData(ob, val, sub)
elif key == 'ParticleSystem':
parseParticleSystem(ob, val, sub)
elif key == 'FieldSettings':
parseDefault(ob.field, sub, {}, [])
else:
defaultKey(key, val, sub, ob, ['type', 'data'])
Thomas Larsson
committed
if ob.type == 'MESH':
bpy.ops.object.shade_smooth()
else:
print("Context", ob, bpy.context.object, bpy.context.scene.objects.active)
return
Thomas Larsson
committed
# print( "Creating object %s %s %s" % (typ, name, data) )
ob = bpy.data.objects.new(name, data)
if data:
loadedData[typ.capitalize()][datName] = data
loadedData['Object'][name] = ob
return ob
Thomas Larsson
committed
if data and ob.data is None:
ob.data = data
scn = bpy.context.scene
scn.objects.link(ob)
scn.objects.active = ob
#print("Linked object", ob)
#print("Scene", scn)
#print("Active", scn.objects.active)
#print("Context", bpy.context.object)
return ob
def setObjectAndData(args, typ):
datName = args[0]
obName = args[1]
#bpy.ops.object.add(type=typ)
ob = bpy.context.object
ob.name = obName
ob.data.name = datName
loadedData[typ][datName] = ob.data
loadedData['Object'][obName] = ob
return ob.data
#
name = args[0]
typ = args[1]
if typ == 'PARTICLE_SYSTEM':
return None
mod = ob.modifiers.new(name, typ)
for (key, val, sub) in tokens:
if key == 'HookAssignNth':
if val[0] == 'CURVE':
hookAssignNth(mod, int(val[1]), True, ob.data.splines[0].points)
elif val[0] == 'LATTICE':
hookAssignNth(mod, int(val[1]), False, ob.data.points)
elif val[0] == 'MESH':
hookAssignNth(mod, int(val[1]), True, ob.data.vertices)
else:
Thomas Larsson
committed
else:
defaultKey(key, val, sub, mod)
def hookAssignNth(mod, n, select, points):
if select:
for pt in points:
pt.select = False
points[n].select = True
sel = []
for pt in points:
sel.append(pt.select)
#print(mod, sel, n, points)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.object.hook_reset(modifier=mod.name)
bpy.ops.object.hook_select(modifier=mod.name)
bpy.ops.object.hook_assign(modifier=mod.name)
bpy.ops.object.mode_set(mode='OBJECT')
return
# parseParticleSystem(ob, args, tokens):
# parseParticles(particles, args, tokens):
# parseParticle(par, args, tokens):
#
def parseParticleSystem(ob, args, tokens):
print(ob, bpy.context.object)
pss = ob.particle_systems
print(pss, pss.values())
name = args[0]
typ = args[1]
#psys = pss.new(name, typ)
bpy.ops.object.particle_system_add()
print(pss, pss.values())
psys = pss[-1]
psys.name = name
psys.settings.type = typ
loadedData['ParticleSystem'][name] = psys
print("Psys", psys)
for (key, val, sub) in tokens:
if key == 'Particles':
parseParticles(psys, val, sub)
else:
defaultKey(key, val, sub, psys)
particles = psys.particles
bpy.ops.particle.particle_edit_toggle()
n = 0
for (key, val, sub) in tokens:
if key == 'Particle':
parseParticle(particles[n], val, sub)
n += 1
else:
for par in particles:
defaultKey(key, val, sub, par)
bpy.ops.particle.particle_edit_toggle()
return particles
n = 0
for (key, val, sub) in tokens:
if key == 'h':
h = par.hair[n]
h.location = mhxEval(val[0], locals())
h.time = int(val[1])
h.weight = float(val[2])
n += 1
elif key == 'location':
par.location = mhxEval(val[0], locals())
l = []
for t in list_of_tuples:
l.extend(t)
return l
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
if verbosity > 2:
print( "Parsing mesh %s" % args )
mename = args[0]
obname = args[1]
me = bpy.data.meshes.new(mename)
ob = createObject('MESH', obname, me, mename)
verts = []
edges = []
faces = []
vertsTex = []
texFaces = []
for (key, val, sub) in tokens:
if key == 'Verts':
verts = parseVerts(sub)
elif key == 'Edges':
edges = parseEdges(sub)
elif key == 'Faces':
faces = parseFaces(sub)
if faces:
me.from_pydata(verts, [], faces)
else:
me.from_pydata(verts, edges, [])
me.update()
Thomas Larsson
committed
if faces:
try:
me.polygons
BMeshAware = True
except:
BMeshAware = False
Thomas Larsson
committed
Thomas Larsson
committed
nuvlayers = 0
for (key, val, sub) in tokens:
if key == 'Verts' or key == 'Edges' or key == 'Faces':
pass
elif key == 'MeshTextureFaceLayer':
if BMeshAware:
parseUvTextureBMesh(val, sub, me)
else:
parseUvTextureNoBMesh(val, sub, me)
Thomas Larsson
committed
elif key == 'MeshColorLayer':
parseVertColorLayer(val, sub, me)
elif key == 'VertexGroup':
parseVertexGroup(ob, me, val, sub)
elif key == 'ShapeKeys':
parseShapeKeys(ob, me, val, sub)
elif key == 'Material':
Thomas Larsson
committed
try:
mat = loadedData['Material'][val[0]]
except:
mat = None
if mat:
me.materials.append(mat)
else:
defaultKey(key, val, sub, me)
for (key, val, sub) in tokens:
if key == 'Faces':
if BMeshAware:
parseFaces2BMesh(sub, me)
else:
parseFaces2NoBMesh(sub, me)
return me
#
# parseVerts(tokens):
# parseEdges(tokens):
# parseFaces(tokens):
Thomas Larsson
committed
# parseFaces2(tokens, me):
verts = []
for (key, val, sub) in tokens:
if key == 'v':
verts.append( (theScale*float(val[0]), theScale*float(val[1]), theScale*float(val[2])) )
return verts
edges = []
for (key, val, sub) in tokens:
if key == 'e':
edges.append((int(val[0]), int(val[1])))
return edges
Thomas Larsson
committed
def parseFaces(tokens):
faces = []
for (key, val, sub) in tokens:
if key == 'f':
if len(val) == 3:
face = [int(val[0]), int(val[1]), int(val[2])]
elif len(val) == 4:
face = [int(val[0]), int(val[1]), int(val[2]), int(val[3])]
faces.append(face)
return faces
Thomas Larsson
committed
def parseFaces2BMesh(tokens, me):
n = 0
for (key, val, sub) in tokens:
if key == 'ft':
Thomas Larsson
committed
f = me.polygons[n]
f.material_index = int(val[0])
f.use_smooth = int(val[1])
n += 1
elif key == 'ftn':
mn = int(val[1])
us = int(val[2])
npts = int(val[0])
for i in range(npts):
Thomas Larsson
committed
f = me.polygons[n]
f.material_index = mn
f.use_smooth = us
n += 1
elif key == 'mn':
fn = int(val[0])
mn = int(val[1])
Thomas Larsson
committed
f = me.polygons[fn]
f.material_index = mn
elif key == 'ftall':
mat = int(val[0])
smooth = int(val[1])
Thomas Larsson
committed
for f in me.polygons:
f.material_index = mat
f.use_smooth = smooth
return
Thomas Larsson
committed
def parseFaces2NoBMesh(tokens, me):
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
n = 0
for (key, val, sub) in tokens:
if key == 'ft':
f = me.faces[n]
f.material_index = int(val[0])
f.use_smooth = int(val[1])
n += 1
elif key == 'ftn':
mn = int(val[1])
us = int(val[2])
npts = int(val[0])
for i in range(npts):
f = me.faces[n]
f.material_index = mn
f.use_smooth = us
n += 1
elif key == 'mn':
fn = int(val[0])
mn = int(val[1])
f = me.faces[fn]
f.material_index = mn
elif key == 'ftall':
mat = int(val[0])
smooth = int(val[1])
for f in me.faces:
f.material_index = mat
f.use_smooth = smooth
return
Thomas Larsson
committed
# parseUvTexture(args, tokens, me,):
def parseUvTextureBMesh(args, tokens, me):
Thomas Larsson
committed
bpy.ops.mesh.uv_texture_add()
uvtex = me.uv_textures[-1]
uvtex.name = name
Thomas Larsson
committed
loadedData['MeshTextureFaceLayer'][name] = uvloop
parseUvTexDataBMesh(val, sub, uvloop.data)
defaultKey(key, val, sub, uvtex)
def parseUvTexDataBMesh(args, tokens, data):
n = 0
for (key, val, sub) in tokens:
if key == 'vt':
Thomas Larsson
committed
data[n].uv = (float(val[0]), float(val[1]))
n += 1
data[n].uv = (float(val[2]), float(val[3]))
n += 1
data[n].uv = (float(val[4]), float(val[5]))
n += 1
Thomas Larsson
committed
data[n].uv = (float(val[6]), float(val[7]))
n += 1
return
def parseUvTextureNoBMesh(args, tokens, me):
name = args[0]
uvtex = me.uv_textures.new(name = name)
loadedData['MeshTextureFaceLayer'][name] = uvtex
for (key, val, sub) in tokens:
if key == 'Data':
parseUvTexDataNoBMesh(val, sub, uvtex.data)
defaultKey(key, val, sub, uvtex)
return
def parseUvTexDataNoBMesh(args, tokens, data):
n = 0
for (key, val, sub) in tokens:
if key == 'vt':
data[n].uv1 = (float(val[0]), float(val[1]))
data[n].uv2 = (float(val[2]), float(val[3]))
data[n].uv3 = (float(val[4]), float(val[5]))
if len(val) > 6:
data[n].uv4 = (float(val[6]), float(val[7]))
Thomas Larsson
committed
n += 1
return
#
# parseVertColorLayer(args, tokens, me):
# parseVertColorData(args, tokens, data):
#
def parseVertColorLayer(args, tokens, me):
name = args[0]
print("VertColorLayer", name)
vcol = me.vertex_colors.new(name)
loadedData['MeshColorLayer'][name] = vcol
for (key, val, sub) in tokens:
if key == 'Data':
parseVertColorData(val, sub, vcol.data)
else:
defaultKey(key, val, sub, vcol)
n = 0
for (key, val, sub) in tokens:
if key == 'cv':
data[n].color1 = mhxEval(val[0])
data[n].color2 = mhxEval(val[1])
data[n].color3 = mhxEval(val[2])
data[n].color4 = mhxEval(val[3])
Thomas Larsson
committed
n += 1
#
def parseVertexGroup(ob, me, args, tokens):
if verbosity > 2:
print( "Parsing vertgroup %s" % args )
grpName = args[0]
try:
res = mhxEval(args[1])
except:
res = True
if not res:
return
if (toggle & T_Armature) or (grpName in ['Eye_L', 'Eye_R', 'Gums', 'Head', 'Jaw', 'Left', 'Middle', 'Right', 'Scalp']):
try:
group = loadedData['VertexGroup'][grpName]
except KeyError:
group = ob.vertex_groups.new(grpName)
loadedData['VertexGroup'][grpName] = group
for (key, val, sub) in tokens:
if key == 'wv':
group.add( [int(val[0])], float(val[1]), 'REPLACE' )
return
#
# parseShapeKeys(ob, me, args, tokens):
# parseShapeKey(ob, me, args, tokens):
# addShapeKey(ob, name, vgroup, tokens):
# doShape(name):
if (toggle & T_Shapekeys) and (name == 'Basis'):
for (key, val, sub) in tokens:
if key == 'ShapeKey':
parseShapeKey(ob, me, val, sub)
elif key == 'AnimationData':
if me.shape_keys:
parseAnimationData(me.shape_keys, val, sub)
Thomas Larsson
committed
elif key == 'Expression':
prop = "Mhe" + val[0].capitalize()
Thomas Larsson
committed
parseUnits(prop, ob, sub)
elif key == 'Viseme':
name = val[0].upper()
if name in ["REST", "ETC"]:
name = name.capitalize()
prop = "Mhv" + name
Thomas Larsson
committed
parseUnits(prop, ob, sub)
Thomas Larsson
committed
Thomas Larsson
committed
def parseUnits(prop, ob, sub):
string = ""
for words in sub:
unit = words[0].replace("-","_")
value = words[1][0]
string += "%s:%s;" % (unit, value)
rig = ob.parent
rig[prop] = string
if verbosity > 2:
print( "Parsing ob %s shape %s" % (bpy.context.object, args[0] ))
name = args[0]
lr = args[1]
if invalid(args[2]):
return
addShapeKey(ob, name, None, tokens)
elif lr == 'LR':
addShapeKey(ob, name+'_L', 'Left', tokens)
addShapeKey(ob, name+'_R', 'Right', tokens)
else:
skey = ob.shape_key_add(name=name, from_mix=False)
if name != 'Basis':
skey.relative_key = loadedData['ShapeKey']['Basis']
skey.name = name
if vgroup:
skey.vertex_group = vgroup
loadedData['ShapeKey'][name] = skey
for (key, val, sub) in tokens:
if key == 'sv':
index = int(val[0])
pt = skey.data[index].co
pt[0] += theScale*float(val[1])
pt[1] += theScale*float(val[2])
pt[2] += theScale*float(val[3])
else:
defaultKey(key, val, sub, skey)
Thomas Larsson
committed
return
if verbosity > 2:
print( "Parsing armature %s" % args )
Thomas Larsson
committed
amtname = args[0]
obname = args[1]
mode = args[2]
Thomas Larsson
committed
Thomas Larsson
committed
ob = createObject('ARMATURE', obname, amt, amtname)
linkObject(ob, amt)
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.mode_set(mode='EDIT')
heads = {}
tails = {}
for (key, val, sub) in tokens:
if key == 'Bone':
bname = val[0]
if not invalid(val[1]):
bone = amt.edit_bones.new(bname)
parseBone(bone, amt, sub, heads, tails)
loadedData['Bone'][bname] = bone
elif key == 'RecalcRoll':
for bone in amt.edit_bones:
bone.select = False
blist = mhxEval(val[0])
for name in blist:
bone = amt.edit_bones[name]
bone.select = True
bpy.ops.armature.calculate_roll(type='Z')
for bone in amt.edit_bones:
rolls[bone.name] = bone.roll
bpy.ops.object.mode_set(mode='OBJECT')
for bone in amt.bones:
bone['Roll'] = rolls[bone.name]
bpy.ops.object.mode_set(mode='EDIT')
defaultKey(key, val, sub, amt, ['MetaRig'])
Thomas Larsson
committed
Thomas Larsson
committed
#
def parseBone(bone, amt, tokens, heads, tails):
for (key, val, sub) in tokens:
if key == "head":
bone.head = (theScale*float(val[0]), theScale*float(val[1]), theScale*float(val[2]))
elif key == "tail":
bone.tail = (theScale*float(val[0]), theScale*float(val[1]), theScale*float(val[2]))
#elif key == 'restrict_select':
# pass
elif key == 'hide' and val[0] == 'True':
name = bone.name
else:
defaultKey(key, val, sub, bone)
name = args[0]
ob = loadedData['Object'][name]
bpy.context.scene.objects.active = ob
bpy.ops.object.mode_set(mode='POSE')
Thomas Larsson
committed
pbones = ob.pose.bones
nGrps = 0
for (key, val, sub) in tokens:
if key == 'Posebone':
parsePoseBone(pbones, ob, val, sub)
elif key == 'BoneGroup':
parseBoneGroup(ob.pose, nGrps, val, sub)
nGrps += 1
elif key == 'SetProp':
bone = val[0]
prop = val[1]
value = mhxEval(val[2])
defaultKey(key, val, sub, ob.pose)
bpy.ops.object.mode_set(mode='OBJECT')
return ob
#
# parsePoseBone(pbones, args, tokens):
# parseArray(data, exts, args):
#
def parseBoneGroup(pose, nGrps, args, tokens):
if verbosity > 2:
print( "Parsing bonegroup %s" % args )
name = args[0]
bpy.ops.pose.group_add()
bg = pose.bone_groups.active
loadedData['BoneGroup'][name] = bg
for (key, val, sub) in tokens:
defaultKey(key, val, sub, bg)
if invalid(args[1]):
return
name = args[0]
pb = pbones[name]
amt = ob.data
Thomas Larsson
committed
amt.bones.active = pb.bone
for (key, val, sub) in tokens:
if key == 'Constraint':
Thomas Larsson
committed
amt.bones.active = pb.bone
cns = parseConstraint(pb.constraints, pb, val, sub)
Thomas Larsson
committed
amt.bones.active = pb.bone
raise MhxError("MHX bug: Must not exec %s" % expr)
elif key == 'ik_dof':
parseArray(pb, ["ik_dof_x", "ik_dof_y", "ik_dof_z"], val)
elif key == 'ik_limit':
parseArray(pb, ["ik_limit_x", "ik_limit_y", "ik_limit_z"], val)
elif key == 'ik_max':
parseArray(pb, ["ik_max_x", "ik_max_y", "ik_max_z"], val)
elif key == 'ik_min':
parseArray(pb, ["ik_min_x", "ik_min_y", "ik_min_z"], val)
elif key == 'ik_stiffness':
parseArray(pb, ["ik_stiffness_x", "ik_stiffness_y", "ik_stiffness_z"], val)
elif key == 'hide':
#bpy.ops.object.mode_set(mode='OBJECT')
amt.bones[name].hide = mhxEval(val[0])
Thomas Larsson
committed
defaultKey(key, val, sub, pb)
setattr(data, ext, mhxEval(args[n]))
Thomas Larsson
committed
# parseConstraint(constraints, pb, args, tokens)
def parseConstraint(constraints, pb, args, tokens):
if (toggle&T_Opcns and pb):
print("Active")
aob = bpy.context.object
print("ob", aob)
aamt = aob.data
print("amt", aamt)
apose = aob.pose
print("pose", apose)
abone = aamt.bones.active
print("bone", abone)
print('Num cns before', len(list(constraints)))
bpy.ops.pose.constraint_add(type=args[1])
cns = constraints.active
print('and after', pb, cns, len(list(constraints)))
else:
cns = constraints.new(args[1])
cns.name = args[0]
for (key,val,sub) in tokens:
if key == 'invert':
parseArray(cns, ["invert_x", "invert_y", "invert_z"], val)
elif key == 'use':
parseArray(cns, ["use_x", "use_y", "use_z"], val)
elif key == 'pos_lock':
parseArray(cns, ["lock_location_x", "lock_location_y", "lock_location_z"], val)
elif key == 'rot_lock':
parseArray(cns, ["lock_rotation_x", "lock_rotation_y", "lock_rotation_z"], val)
else:
defaultKey(key, val, sub, cns, ["use_target"])
#
# parseCurve (args, tokens):
# parseSpline(cu, args, tokens):
# parseBezier(spline, n, args, tokens):
if verbosity > 2:
print( "Parsing curve %s" % args )
bpy.ops.object.add(type='CURVE')
cu = setObjectAndData(args, 'Curve')
for (key, val, sub) in tokens:
if key == 'Spline':
parseSpline(cu, val, sub)
else:
defaultKey(key, val, sub, cu)
def parseTextCurve (args, tokens):
if verbosity > 2:
print( "Parsing text curve %s" % args )
bpy.ops.object.text_add()
txt = setObjectAndData(args, 'Text')
for (key, val, sub) in tokens:
if key == 'Spline':
parseSpline(txt, val, sub)
elif key == 'BodyFormat':
parseCollection(txt.body_format, sub, [])
elif key == 'EditFormat':
parseDefault(txt.edit_format, sub, {}, [])
elif key == 'Font':
parseDefault(txt.font, sub, {}, [])
elif key == 'TextBox':
parseCollection(txt.body_format, sub, [])
else:
defaultKey(key, val, sub, txt)
def parseSpline(cu, args, tokens):
typ = args[0]
spline = cu.splines.new(typ)
nPointsU = int(args[1])
nPointsV = int(args[2])
#spline.point_count_u = nPointsU
#spline.point_count_v = nPointsV
if typ == 'BEZIER' or typ == 'BSPLINE':
spline.bezier_points.add(nPointsU)
else:
spline.points.add(nPointsU)
n = 0
for (key, val, sub) in tokens:
if key == 'bz':
parseBezier(spline.bezier_points[n], val, sub)
n += 1
elif key == 'pt':
parsePoint(spline.points[n], val, sub)
n += 1
else:
defaultKey(key, val, sub, spline)
Thomas Larsson
committed
def parseBezier(bez, args, tokens):
bez.co = mhxEval(args[0])
Thomas Larsson
committed
bez.co = theScale*bez.co
bez.handle1 = mhxEval(args[1])
bez.handle2 = mhxEval(args[3])
def parsePoint(pt, args, tokens):
pt.co = mhxEval(args[0])
print(" pt", pt.co)
if verbosity > 2:
print( "Parsing lattice %s" % args )
bpy.ops.object.add(type='LATTICE')
Thomas Larsson
committed
lat = setObjectAndData(args, 'Lattice')
for (key, val, sub) in tokens:
if key == 'Points':
parseLatticePoints(val, sub, lat.points)
else:
defaultKey(key, val, sub, lat)
n = 0
for (key, val, sub) in tokens:
if key == 'pt':
v = points[n].co_deform
v.x = theScale*float(val[0])
v.y = theScale*float(val[1])
v.z = theScale*float(val[2])
# parseLamp (args, tokens):
# parseFalloffCurve(focu, args, tokens):
def parseLamp (args, tokens):
if verbosity > 2:
print( "Parsing lamp %s" % args )
bpy.ops.object.add(type='LAMP')
Thomas Larsson
committed
lamp = setObjectAndData(args, 'Lamp')
for (key, val, sub) in tokens:
if key == 'FalloffCurve':
parseFalloffCurve(lamp.falloff_curve, val, sub)
else:
defaultKey(key, val, sub, lamp)
def parseFalloffCurve(focu, args, tokens):
# parseGroup (args, tokens):
# parseGroupObjects(args, tokens, grp):
#
def parseGroup (args, tokens):
if verbosity > 2:
print( "Parsing group %s" % args )
grpName = args[0]
grp = bpy.data.groups.new(grpName)
loadedData['Group'][grpName] = grp
for (key, val, sub) in tokens:
if key == 'Objects':
parseGroupObjects(val, sub, grp)
else:
defaultKey(key, val, sub, grp)
def parseGroupObjects(args, tokens, grp):
Thomas Larsson
committed
rig = None
for (key, val, sub) in tokens:
if key == 'ob':
try:
ob = loadedData['Object'][val[0]]
grp.objects.link(ob)
except:
Thomas Larsson
committed
ob = None
if ob:
print(ob, ob.type, rig, ob.parent)
if ob.type == 'ARMATURE':
rig = ob
elif ob.type == 'EMPTY' and rig and not ob.parent:
ob.parent = rig
print("SSS")
#
def parseWorld (args, tokens):
if verbosity > 2:
print( "Parsing world %s" % args )
world = bpy.context.scene.world
for (key, val, sub) in tokens:
if key == 'Lighting':
parseDefault(world.lighting, sub, {}, [])
elif key == 'Mist':
parseDefault(world.mist, sub, {}, [])
elif key == 'Stars':
parseDefault(world.stars, sub, {}, [])
else:
defaultKey(key, val, sub, world)
return
#
# parseScene (args, tokens):
# parseRenderSettings(render, args, tokens):
# parseToolSettings(tool, args, tokens):
#
def parseScene (args, tokens):
if verbosity > 2:
print( "Parsing scene %s" % args )
scn = bpy.context.scene
for (key, val, sub) in tokens:
if key == 'NodeTree':
scn.use_nodes = True
parseNodeTree(scn, val, sub)
elif key == 'GameData':
parseDefault(scn.game_data, sub, {}, [])
elif key == 'KeyingSet':
pass
#parseDefault(scn.keying_sets, sub, {}, [])
elif key == 'ObjectBase':
pass
#parseDefault(scn.bases, sub, {}, [])
elif key == 'RenderSettings':
parseRenderSettings(scn.render, sub, [])
elif key == 'ToolSettings':
Thomas Larsson
committed
subkeys = {'ImagePaint' : "image_paint",
'Sculpt' : "sculpt",
'VertexPaint' : "vertex_paint",
'WeightPaint' : "weight_paint" }
parseDefault(scn.tool_settings, sub, subkeys, [])
elif key == 'UnitSettings':
parseDefault(scn.unit_settings, sub, {}, [])
else:
defaultKey(key, val, sub, scn)
def parseRenderSettings(render, args, tokens):
if verbosity > 2:
print( "Parsing RenderSettings %s" % args )
for (key, val, sub) in tokens:
if key == 'Layer':
pass
#parseDefault(scn.layers, sub, [])
else:
defaultKey(key, val, sub, render)
# parseDefineProperty(args, tokens):
def parseDefineProperty(args, tokens):
prop = "%sProperty" % (args[1])
c = '('
for option in args[2:]:
prop += "%s %s" % (c, option)
prop += ')'
setattr(bpy.types.Object, args[0], prop)
return
#
# correctRig(args):
#
def correctRig(args):
human = args[0]
Thomas Larsson
committed
print("CorrectRig %s" % human)
try:
ob = loadedData['Object'][human]
except:
ob.MhxShapekeyDrivers = (toggle&T_Shapekeys != 0 and toggle&T_ShapeDrivers != 0)
bpy.context.scene.objects.active = ob
bpy.ops.object.mode_set(mode='POSE')
amt = ob.data
cnslist = []
for pb in ob.pose.bones:
for cns in pb.constraints:
if cns.type == 'CHILD_OF':
cnslist.append((pb, cns, cns.influence))
cns.influence = 0
for (pb, cns, inf) in cnslist:
amt.bones.active = pb.bone
cns.influence = 1
#print("Childof %s %s %s %.2f" % (amt.name, pb.name, cns.name, inf))
bpy.ops.constraint.childof_clear_inverse(constraint=cns.name, owner='BONE')