[Bf-extensions-cvs] [6cef5e01] master: glTF importer: use bpy.utils.escape_identifier to escape names for action paths

Julien Duroure noreply at git.blender.org
Thu Oct 8 19:20:08 CEST 2020


Commit: 6cef5e013e54da23990ebb26ef9bbc15f3977c8d
Author: Julien Duroure
Date:   Thu Oct 8 19:19:20 2020 +0200
Branches: master
https://developer.blender.org/rBA6cef5e013e54da23990ebb26ef9bbc15f3977c8d

glTF importer: use bpy.utils.escape_identifier to escape names for action paths

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py
M	io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index a13ef211..2599fa21 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
 bl_info = {
     'name': 'glTF 2.0 format',
     'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
-    "version": (1, 4, 33),
+    "version": (1, 4, 34),
     'blender': (2, 91, 0),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py b/io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py
index d41b7892..6cbc85f4 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py
@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import json
 import bpy
 from mathutils import Vector
 
@@ -90,7 +89,10 @@ class BlenderNodeAnim():
         if vnode.type == VNode.Bone:
             # Need to animate the pose bone when the node is a bone.
             group_name = vnode.blender_bone_name
-            blender_path = "pose.bones[%s].%s" % (json.dumps(vnode.blender_bone_name), blender_path)
+            blender_path = 'pose.bones["%s"].%s' % (
+                bpy.utils.escape_identifier(vnode.blender_bone_name),
+                blender_path
+            )
 
             # We have the final TRS of the bone in values. We need to give
             # the TRS of the pose bone though, which is relative to the edit
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py b/io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py
index 1bf67213..ac36904a 100644
--- a/io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py
@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import json
 import bpy
 
 from ...io.imp.gltf2_io_binary import BinaryData
@@ -75,7 +74,7 @@ class BlenderWeightAnim():
             if pymesh.shapekey_names[sk] is not None: # Do not animate shapekeys not created
                 coords[1::2] = (values[offset + stride * i + sk][0] for i in range(len(keys)))
                 kb_name = pymesh.shapekey_names[sk]
-                data_path = "key_blocks[" + json.dumps(kb_name) + "].value"
+                data_path = 'key_blocks["%s"].value' % bpy.utils.escape_identifier(kb_name)
 
                 make_fcurve(
                     action,



More information about the Bf-extensions-cvs mailing list