Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShrinivas Kulkarni <shrinivk@gmail.com>2020-01-09 12:01:26 +0300
committerShrinivas Kulkarni <shrinivk@gmail.com>2020-01-09 12:01:26 +0300
commitb2c68d8eeb87318f1e57f48d7f7049c3fa6d0ca1 (patch)
tree90d93ddf3dc07ac09d8926947b279b069141f74f /curve_assign_shapekey.py
parente7a8ab248112edffe09b574b68352160b59021db (diff)
curve_assign_shapekey: 1) Passed target & shape key objects as params to main function 2) Fix to retain first key name, if target already has shape keys
Diffstat (limited to 'curve_assign_shapekey.py')
-rw-r--r--curve_assign_shapekey.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/curve_assign_shapekey.py b/curve_assign_shapekey.py
index 318e2b25..f6f18500 100644
--- a/curve_assign_shapekey.py
+++ b/curve_assign_shapekey.py
@@ -3,7 +3,7 @@
# This Blender add-on assigns one or more Bezier Curves as shape keys to another
# Bezier Curve
#
-# Supported Blender Version: 2.80 Beta
+# Supported Blender Versions: 2.8x
#
# Copyright (C) 2019 Shrinivas Kulkarni
#
@@ -400,18 +400,12 @@ class Path:
self.curve.data = self.getNewCurveData()
bpy.data.curves.remove(curveData)
-def main(removeOriginal, space, matchParts, matchCriteria, alignBy, alignValues):
- targetObj = bpy.context.active_object
- if(targetObj == None or not isBezier(targetObj)):
- return
+def main(targetObj, shapekeyObjs, removeOriginal, space, matchParts, \
+ matchCriteria, alignBy, alignValues):
target = Path(targetObj)
- shapekeys = [Path(c) for c in bpy.context.selected_objects if isBezier(c) \
- and c != bpy.context.active_object]
-
- if(len(shapekeys) == 0):
- return
+ shapekeys = [Path(c) for c in shapekeyObjs]
shapekeys = getExistingShapeKeyPaths(target) + shapekeys
userSel = [target] + shapekeys
@@ -437,18 +431,20 @@ def main(removeOriginal, space, matchParts, matchCriteria, alignBy, alignValues)
for j, part in enumerate(path.parts):
part.toClose = allToClose[j]
- target.updateCurve()
+ if(targetObj.data.shape_keys != None):
+ skName = targetObj.data.shape_keys.key_blocks[0].name
+ else:
+ skName = 'Basis'
- target.curve.shape_key_add(name = 'Basis')
+ target.updateCurve()
+ target.curve.shape_key_add(name = skName)
addShapeKeys(target.curve, shapekeys, space)
if(removeOriginal):
for path in userSel:
if(path.curve != target.curve):
- safeRemoveCurveObj(path.curve)
-
- return {}
+ safeRemoveObj(path.curve)
def getSplineSegs(spline):
p = spline.bezier_points
@@ -743,7 +739,7 @@ def addShapeKeys(curve, paths, space):
key.data[i].handle_right = pt[2]
#TODO: Remove try
-def safeRemoveCurveObj(obj):
+def safeRemoveObj(obj):
try:
collections = obj.users_collection
@@ -791,9 +787,14 @@ class AssignShapeKeysOp(Operator):
alignVal2 = params.alignVal2
alignVal3 = params.alignVal3
- createdObjsMap = main(removeOriginal, space, \
- matchParts, [matchCri1, matchCri2, matchCri3], \
- alignBy, [alignVal1, alignVal2, alignVal3])
+ targetObj = bpy.context.active_object
+ shapekeyObjs = [obj for obj in bpy.context.selected_objects if isBezier(obj) \
+ and obj != targetObj]
+
+ if(targetObj != None and isBezier(targetObj) and len(shapekeyObjs) > 0):
+ main(targetObj, shapekeyObjs, removeOriginal, space, \
+ matchParts, [matchCri1, matchCri2, matchCri3], \
+ alignBy, [alignVal1, alignVal2, alignVal3])
return {'FINISHED'}