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>2019-06-22 12:00:02 +0300
committerShrinivas Kulkarni <shrinivk@gmail.com>2019-06-22 12:01:09 +0300
commitc9a673af1e662976101a0a89f8683dec3dbdf24a (patch)
tree2ab50b7d5388ebe31b2d20d606c9f7ebb6041141 /curve_assign_shapekey.py
parent5fbb27d65ceac46d4377d8682192d4b93c7476bf (diff)
curve_assign_shapekey: modified the target object instead of making a copy
Diffstat (limited to 'curve_assign_shapekey.py')
-rw-r--r--curve_assign_shapekey.py36
1 files changed, 14 insertions, 22 deletions
diff --git a/curve_assign_shapekey.py b/curve_assign_shapekey.py
index 8135184c..3fe88475 100644
--- a/curve_assign_shapekey.py
+++ b/curve_assign_shapekey.py
@@ -381,24 +381,15 @@ class Path:
return newCurveData
- def addCurve(self):
- curveData = self.getNewCurveData()
- obj = self.curve.copy()
- obj.data = curveData
- if(obj.data.shape_keys != None):
- keyblocks = reversed(obj.data.shape_keys.key_blocks)
+ def updateCurve(self):
+ curveData = self.curve.data
+ #Remove existing shape keys first
+ if(curveData.shape_keys != None):
+ keyblocks = reversed(curveData.shape_keys.key_blocks)
for sk in keyblocks:
- obj.shape_key_remove(sk)
-
- collections = self.curve.users_collection
- for collection in collections:
- collection.objects.link(obj)
-
- if(self.curve.name in bpy.context.scene.collection.objects and \
- obj.name not in bpy.context.scene.collection.objects):
- bpy.context.scene.collection.objects.link(obj)
-
- return obj
+ self.curve.shape_key_remove(sk)
+ self.curve.data = self.getNewCurveData()
+ bpy.data.curves.remove(curveData)
def main(removeOriginal, space, matchParts, matchCriteria, alignBy, alignValues):
targetObj = bpy.context.active_object
@@ -437,15 +428,16 @@ def main(removeOriginal, space, matchParts, matchCriteria, alignBy, alignValues)
for j, part in enumerate(path.parts):
part.toClose = allToClose[j]
- curve = target.addCurve()
+ target.updateCurve()
- curve.shape_key_add(name = 'Basis')
+ target.curve.shape_key_add(name = 'Basis')
- addShapeKey(curve, shapekeys, space)
+ addShapeKeys(target.curve, shapekeys, space)
if(removeOriginal):
for path in userSel:
- safeRemoveCurveObj(path.curve)
+ if(path.curve != target.curve):
+ safeRemoveCurveObj(path.curve)
return {}
@@ -730,7 +722,7 @@ def getExistingShapeKeyPaths(path):
paths.append(Path(obj, datacopy, key.name))
return paths
-def addShapeKey(curve, paths, space):
+def addShapeKeys(curve, paths, space):
for path in paths:
key = curve.shape_key_add(name = path.name)
pts = [pt for pset in path.getBezierPtsBySpline() for pt in pset]