Newer
Older
defaultKey(key, val, sub, "img", ['depth', 'dirty', 'has_data', 'size', 'type'], globals(), locals())
print ("Image %s" % img )
loadedData['Image'][imgName] = img
return img
#
# parseObject(args, tokens):
# createObject(type, name, data, datName):
# setObjectAndData(args, typ):
#
if verbosity > 2:
print( "Parsing object %s" % args )
name = args[0]
typ = args[1]
datName = args[2]
if typ == 'EMPTY':
ob = bpy.data.objects.new(name, None)
loadedData['Object'][name] = ob
linkObject(ob, None)
else:
try:
data = loadedData[typ.capitalize()][datName]
except:
MyError("Failed to find data: %s %s %s" % (name, typ, datName))
return
try:
ob = loadedData['Object'][name]
bpy.context.scene.objects.active = ob
#print("Found data", ob)
except:
ob = None
if ob is None:
print("Create", name, data, datName)
ob = createObject(typ, name, data, datName)
print("created", ob)
linkObject(ob, data)
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'], globals(), locals())
Thomas Larsson
committed
# Needed for updating layers
if bpy.context.object == ob:
pass
'''
if ob.data in ['MESH', 'ARMATURE']:
print(ob, ob.data)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.object.mode_set(mode='OBJECT')
'''
else:
print("Context", ob, bpy.context.object, bpy.context.scene.objects.active)
return
# 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
if data and ob.data is None:
ob.data = data
print("Data linked", ob, ob.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:
else:
defaultKey(key, val, sub, 'mod', [], globals(), locals())
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', [], globals(), locals())
return 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', [], globals(), locals())
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 = eval(val[0])
h.time = int(val[1])
h.weight = float(val[2])
n += 1
elif key == 'location':
par.location = eval(val[0])
return
l = []
for t in list_of_tuples:
l.extend(t)
return l
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
global todo
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
nuvlayers = 0
for (key, val, sub) in tokens:
if key == 'Verts' or key == 'Edges' or key == 'Faces':
pass
elif key == 'MeshTextureFaceLayer':
parseUvTexture(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':
try:
mat = loadedData['Material'][val[0]]
except:
mat = None
if mat:
me.materials.append(mat)
else:
defaultKey(key, val, sub, "me", [], globals(), locals())
for (key, val, sub) in tokens:
if key == 'Faces':
parseFaces2(sub, me)
print(me)
return me
#
# parseVerts(tokens):
# parseEdges(tokens):
# parseFaces(tokens):
# 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
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
edges = []
for (key, val, sub) in tokens:
if key == 'e':
edges.append((int(val[0]), int(val[1])))
return edges
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
def parseFaces2(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
# parseUvTexture(args, tokens, me,):
Thomas Larsson
committed
bpy.ops.mesh.uv_texture_add()
uvtex = me.uv_textures[-1]
uvtex.name = name
Thomas Larsson
committed
uvloop = me.uv_loop_layers[-1]
loadedData['MeshTextureFaceLayer'][name] = uvloop
Thomas Larsson
committed
parseUvTexData(val, sub, uvloop.data)
else:
defaultKey(key, val, sub, "uvtex", [], globals(), locals())
return
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
else:
pass
#for i in range(n):
# defaultKey(key, val, sub, "data[i]", [], globals(), locals())
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", [], globals(), locals())
return
n = 0
for (key, val, sub) in tokens:
if key == 'cv':
data[n].color1 = eval(val[0])
data[n].color2 = eval(val[1])
data[n].color3 = eval(val[2])
data[n].color4 = eval(val[3])
n += 1
return
#
def parseVertexGroup(ob, me, args, tokens):
if verbosity > 2:
print( "Parsing vertgroup %s" % args )
grpName = args[0]
try:
res = eval(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_Shape+T_Face) and (name == 'Basis'):
return True
else:
return (toggle & T_Face)
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)
ob.active_shape_key_index = 0
print("Shapekeys parsed")
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", [], globals(), locals())
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
global toggle
if verbosity > 2:
print( "Parsing armature %s" % args )
amtname = args[0]
obname = args[1]
mode = args[2]
amt = bpy.data.armatures.new(amtname)
ob = createObject('ARMATURE', obname, amt, amtname)
linkObject(ob, amt)
print("Linked")
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 = eval(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')
else:
defaultKey(key, val, sub, "amt", ['MetaRig'], globals(), locals())
bpy.ops.object.mode_set(mode='OBJECT')
return amt
#
# parseBone(bone, amt, tokens, heads, tails):
#
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
'''
#bpy.ops.object.mode_set(mode='OBJECT')
pbone = amt.bones[name]
pbone.hide = True
print("Hide", pbone, pbone.hide)
#bpy.ops.object.mode_set(mode='EDIT')
'''
else:
defaultKey(key, val, sub, "bone", [], globals(), locals())
return bone
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
global todo
name = args[0]
ob = loadedData['Object'][name]
bpy.context.scene.objects.active = ob
bpy.ops.object.mode_set(mode='POSE')
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 = eval(val[2])
pb = pbones[bone]
print("Setting", pb, prop, val)
pb[prop] = value
print("Prop set", pb[prop])
else:
defaultKey(key, val, sub, "ob.pose", [], globals(), locals())
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", [], globals(), locals())
return
global todo
if invalid(args[1]):
return
name = args[0]
pb = pbones[name]
amt = ob.data
amt.bones.active = pb.bone
for (key, val, sub) in tokens:
if key == 'Constraint':
amt.bones.active = pb.bone
cns = parseConstraint(pb.constraints, pb, val, sub)
amt.bones.active = pb.bone
print(expr)
exec(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 = eval(val[0])
#bpy.ops.object.mode_set(mode='POSE')
else:
defaultKey(key, val, sub, "pb", [], globals(), locals())
#print("pb %s done" % name)
return
n = 1
for ext in exts:
expr = "data.%s = %s" % (ext, args[n])
# print(expr)
exec(expr)
n += 1
return
# 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", [], globals(), locals())
#
# parseCurve (args, tokens):
# parseSpline(cu, args, tokens):
# parseBezier(spline, n, args, tokens):
global todo
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", [], globals(), locals())
return
def parseTextCurve (args, tokens):
global todo
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", [], globals(), locals())
return
def parseSpline(cu, args, tokens):
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
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", [], globals(), locals())
return
def parseBezier(bez, args, tokens):
bez.co = eval(args[0])
bez.co = theScale*bez.co
bez.handle1 = eval(args[1])
bez.handle1_type = args[2]
bez.handle2 = eval(args[3])
bez.handle2_type = args[4]
return
def parsePoint(pt, args, tokens):
print(" pt", pt.co)
global todo
if verbosity > 2:
print( "Parsing lattice %s" % args )
bpy.ops.object.add(type='LATTICE')
lat = setObjectAndData(args, 'Lattice')
for (key, val, sub) in tokens:
if key == 'Points':
parseLatticePoints(val, sub, lat.points)
else:
defaultKey(key, val, sub, "lat", [], globals(), locals())
return
global todo
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):
global todo
if verbosity > 2:
print( "Parsing lamp %s" % args )
bpy.ops.object.add(type='LAMP')
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", [], globals(), locals())
return
def parseFalloffCurve(focu, args, tokens):
# parseGroup (args, tokens):
# parseGroupObjects(args, tokens, grp):
#
def parseGroup (args, tokens):
global todo
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", [], globals(), locals())
return
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):
global todo
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", [], globals(), locals())
return
#
# parseScene (args, tokens):
# parseRenderSettings(render, args, tokens):
# parseToolSettings(tool, args, tokens):
#
def parseScene (args, tokens):
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
global todo
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':
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", [], globals(), locals())
return
def parseRenderSettings(render, args, tokens):
global todo
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", [], globals(), locals())
return
# parseDefineProperty(args, tokens):
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
def parseDefineProperty(args, tokens):
expr = "bpy.types.Object.%s = %sProperty" % (args[0], args[1])
c = '('
for option in args[2:]:
expr += "%s %s" % (c, option)
c = ','
expr += ')'
#print(expr)
exec(expr)
#print("Done")
return
#
# correctRig(args):
#
def correctRig(args):
human = args[0]
print("CorrectRig %s" % human)
try:
ob = loadedData['Object'][human]
except:
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')
bpy.ops.constraint.childof_set_inverse(constraint=cns.name, owner='BONE')
cns.influence = 0