[Bf-extensions-cvs] [d8402cf4] master: io_import_lipSync_Importer: adress the Prop error on reload
lijenstina
noreply at git.blender.org
Fri Jun 16 17:07:13 CEST 2017
Commit: d8402cf4812635b92f55160e03b39a202f14ddbc
Author: lijenstina
Date: Fri Jun 16 17:06:24 2017 +0200
Branches: master
https://developer.blender.org/rBACd8402cf4812635b92f55160e03b39a202f14ddbc
io_import_lipSync_Importer: adress the Prop error on reload
Bumped version to 0.5.2
Part of the T51547:
Move the registration of scene properties outside the Panel
as storing them there would make all sorts of nice things
after a reload
UI properties are moved to an already existing regMenuTypes
PropertyGroup
Pep8 cleanup
Replace bpy.props star import with a tuple one
The refactor is only related to address the register/reload
as the logic of the import is left untouched
Should be no functional changes on the user's side
nor other bugs / issues are fixed
===================================================================
M io_import_lipSync_Importer.py
===================================================================
diff --git a/io_import_lipSync_Importer.py b/io_import_lipSync_Importer.py
index fe610c9c..89d70a96 100644
--- a/io_import_lipSync_Importer.py
+++ b/io_import_lipSync_Importer.py
@@ -18,96 +18,105 @@
bl_info = {
"name": "LipSync Importer & Blinker",
- "author": "Yousef Harfoush - bat3a ;)",
- "version": (0, 5, 1),
+ "author": "Yousef Harfoush - bat3a)",
+ "version": (0, 5, 2),
"blender": (2, 70, 0),
"location": "3D window > Tool Shelf",
"description": "Plots Moho (Papagayo, Jlipsync, Yolo) file "
- "to frames and adds automatic blinking",
+ "to frames and adds automatic blinking",
"warning": "",
- "wiki_url": "http://wiki.blender.org/index.php?title=Extensions:2.6/Py/"
- "Scripts/Import-Export/Lipsync Importer",
+ "wiki_url": "https://wiki.blender.org/index.php?title=Extensions:2.6/Py/"
+ "Scripts/Import-Export/Lipsync Importer",
"tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
"category": "Import-Export"}
-import bpy, re
+import bpy
+import re
from random import random
-from bpy.props import *
-from bpy.props import IntProperty, FloatProperty, StringProperty
+from bpy.props import (
+ EnumProperty,
+ IntProperty,
+ FloatProperty,
+ StringProperty,
+ PointerProperty,
+ )
global lastPhoneme
-lastPhoneme="nothing"
+lastPhoneme = "nothing"
+
# add blinking
def blinker():
scn = bpy.context.scene
- obj = bpy.context.object
if scn.regMenuTypes.enumBlinkTypes == '0':
modifier = 0
elif scn.regMenuTypes.enumBlinkTypes == '1':
- modifier = scn.blinkMod
+ modifier = scn.regMenuTypes.blinkMod
- #creating keys with blinkNm count
- for y in range(scn.blinkNm):
- frame = y * scn.blinkSp + int(random()*modifier)
+ # creating keys with blinkNm count
+ for y in range(scn.regMenuTypes.blinkNm):
+ frame = y * scn.regMenuTypes.blinkSp + int(random() * modifier)
createShapekey('blink', frame)
-# -----------code contributed by dalai felinto adds armature support modified by me-------------------
+
+# -- code contributed by dalai felinto adds armature support modified by me --
bone_keys = {
-"AI": ('location', 0),
-"E": ('location', 1),
-"FV": ('location', 2),
-"L": ('rotation_euler', 0),
-"MBP": ('rotation_euler', 1),
-"O": ('rotation_euler', 2),
-"U": ('scale', 0),
-"WQ": ('scale', 1),
-"etc": ('scale', 2),
-"rest": ('ik_stretch', -1)
+ "AI": ('location', 0),
+ "E": ('location', 1),
+ "FV": ('location', 2),
+ "L": ('rotation_euler', 0),
+ "MBP": ('rotation_euler', 1),
+ "O": ('rotation_euler', 2),
+ "U": ('scale', 0),
+ "WQ": ('scale', 1),
+ "etc": ('scale', 2),
+ "rest": ('ik_stretch', -1)
}
+
def lipsyncerBone():
# reading imported file & creating keys
- object = bpy.context.object
scene = bpy.context.scene
bone = bpy.context.active_pose_bone
resetBoneScale(bone)
- f=open(scene.fpath) # importing file
- f.readline() # reading the 1st line that we don"t need
+ f = open(scene.regMenuTypes.fpath) # importing file
+ f.readline() # reading the 1st line that we don"t need
for line in f:
# removing new lines
lsta = re.split("\n+", line)
# building a list of frames & shapes indexes
- lst = re.split(":? ", lsta[0])# making a list of a frame & number
+ lst = re.split(":? ", lsta[0]) # making a list of a frame & number
frame = int(lst[0])
- for key,attribute in bone_keys.items():
+ for key, attribute in bone_keys.items():
if lst[1] == key:
createBoneKeys(key, bone, attribute, frame)
+
def resetBoneScale(bone):
# set the attributes used by papagayo to 0.0
- for attribute,index in bone_keys.values():
+ for attribute, index in bone_keys.values():
if index != -1:
- #bone.location[0] = 0.0
+ # bone.location[0] = 0.0
exec("bone.%s[%d] = %f" % (attribute, index, 0.0))
else:
exec("bone.%s = %f" % (attribute, 0.0))
+
def addBoneKey(bone, data_path, index=-1, value=None, frame=0, group=""):
# set a value and keyframe for the bone
# it assumes the 'bone' variable was defined before
# and it's the current selected bone
- frame=bpy.context.scene.frame_current
- if value != None:
+ frame = bpy.context.scene.frame_current
+ if value is not None:
if index != -1:
# bone.location[0] = 0.0
exec("bone.%s[%d] = %f" % (data_path, index, value))
@@ -117,37 +126,38 @@ def addBoneKey(bone, data_path, index=-1, value=None, frame=0, group=""):
# bone.keyframe_insert("location", 0, 10.0, "Lipsync")
exec('bone.keyframe_insert("%s", %d, %f, "%s")' % (data_path, index, frame, group))
+
# creating keys with offset and eases for a phonem @ the Skframe
def createBoneKeys(phoneme, bone, attribute, frame):
global lastPhoneme
scene = bpy.context.scene
- object = bpy.context.object
- offst = scene.offset # offset value
- skVlu = scene.skscale # shape key value
+ offst = scene.regMenuTypes.offset # offset value
+ skVlu = scene.regMenuTypes.skscale # shape key value
- #in case of Papagayo format
- if scene.regMenuTypes.enumFileTypes == '0' :
- frmIn = scene.easeIn # ease in value
- frmOut = scene.easeOut # ease out value
- hldIn = scene.holdGap # holding time value
+ # in case of Papagayo format
+ if scene.regMenuTypes.enumFileTypes == '0':
+ frmIn = scene.regMenuTypes.easeIn # ease in value
+ frmOut = scene.regMenuTypes.easeOut # ease out value
+ hldIn = scene.regMenuTypes.holdGap # holding time value
- #in case of Jlipsync format or Yolo
- elif scene.regMenuTypes.enumFileTypes == '1' :
+ # in case of Jlipsync format or Yolo
+ elif scene.regMenuTypes.enumFileTypes == '1':
frmIn = 1
frmOut = 1
hldIn = 0
# inserting the In key only when phonem change or when blinking
- if lastPhoneme!=phoneme or eval(scene.regMenuTypes.enumModeTypes) == 1:
- addBoneKey(bone, attribute[0], attribute[1], 0.0, offst+frame-frmIn, "Lipsync")
+ if lastPhoneme != phoneme or eval(scene.regMenuTypes.enumModeTypes) == 1:
+ addBoneKey(bone, attribute[0], attribute[1], 0.0, offst + frame - frmIn, "Lipsync")
- addBoneKey(bone, attribute[0], attribute[1], skVlu, offst+frame, "Lipsync")
- addBoneKey(bone, attribute[0], attribute[1], skVlu, offst+frame+hldIn, "Lipsync")
- addBoneKey(bone, attribute[0], attribute[1], 0.0, offst+frame+hldIn+frmOut, "Lipsync")
+ addBoneKey(bone, attribute[0], attribute[1], skVlu, offst + frame, "Lipsync")
+ addBoneKey(bone, attribute[0], attribute[1], skVlu, offst + frame + hldIn, "Lipsync")
+ addBoneKey(bone, attribute[0], attribute[1], 0.0, offst + frame + hldIn + frmOut, "Lipsync")
+
+ lastPhoneme = phoneme
- lastPhoneme=phoneme
# -------------------------------------------------------------------------------
@@ -157,8 +167,8 @@ def lipsyncer():
obj = bpy.context.object
scn = bpy.context.scene
- f=open(scn.fpath) # importing file
- f.readline() # reading the 1st line that we don"t need
+ f = open(scn.regMenuTypes.fpath) # importing file
+ f.readline() # reading the 1st line that we don"t need
for line in f:
@@ -166,13 +176,14 @@ def lipsyncer():
lsta = re.split("\n+", line)
# building a list of frames & shapes indexes
- lst = re.split(":? ", lsta[0])# making a list of a frame & number
+ lst = re.split(":? ", lsta[0]) # making a list of a frame & number
frame = int(lst[0])
for key in obj.data.shape_keys.key_blocks:
if lst[1] == key.name:
createShapekey(key.name, frame)
+
# creating keys with offset and eases for a phonem @ the frame
def createShapekey(phoneme, frame):
@@ -182,41 +193,43 @@ def createShapekey(phoneme, frame):
obj = bpy.context.object
objSK = obj.data.shape_keys
- offst = scn.offset # offset value
- skVlu = scn.skscale # shape key value
+ offst = scn.regMenuTypes.offset # offset value
+ skVlu = scn.regMenuTypes.skscale # shape key value
- #in case of Papagayo format
- if scn.regMenuTypes.enumFileTypes == '0' :
- frmIn = scn.easeIn # ease in value
- frmOut = scn.easeOut # ease out value
- hldIn = scn.holdGap # holding time value
+ # in case of Papagayo format
+ if scn.regMenuTypes.enumFileTypes == '0':
+ frmIn = scn.regMenuTypes.easeIn # ease in value
+ frmOut = scn.regMenuTypes.easeOut # ease out value
+ hldIn = scn.regMenuTypes.holdGap # holding time value
- #in case of Jlipsync format or Yolo
- elif scn.regMenuTypes.enumFileTypes == '1' :
+ # in case of Jlipsync format or Yolo
+ elif scn.regMenuTypes.enumFileTypes == '1':
frmIn = 1
frmOut = 1
hldIn = 0
# inserting the In key only when phonem change or when blinking
- if lastPhoneme!=phoneme or eval(scn.regMenuTypes.enumModeTypes) == 1:
- objSK.key_blocks[phoneme].value=0.0
- objSK.key_blocks[phoneme].keyframe_insert("value",
- -1, offst+frame-frmIn, "Lipsync")
-
- objSK.key_blocks[phoneme].value=skVlu
- objSK.key_blocks[phoneme].keyframe_insert("value",
- -1, offst+frame, "Lipsync")
-
- objSK.key_blocks[phoneme].value=skVlu
- objSK.key_blocks[phoneme].keyframe_insert("value",
- -1, offst+frame+hldIn, "Lipsync")
-
- objSK.key_blocks[phoneme].value=0.0
- objSK.key_blocks[phoneme].keyframe_insert("value",
- -1, offst+frame+hldIn+frmOut, "Lipsync")
-
+ if lastPhoneme != phoneme or eval(scn.regMenuTypes.enumModeTypes) == 1:
+ objSK.key_blocks[phoneme].value = 0.0
+ objSK.key_blocks[phoneme].keyframe_insert(
+ "value", -1, offst + frame - frmIn, "Lipsync"
+ )
+
+ objSK.key_blocks[phoneme].value = skVlu
+ objSK.key_block
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list