こんにちは皆私はPythonで初心者です。私のコードに問題があります。特定のフォルダからすべての.BVHファイルを読み込みたいのですが、プログラムは最初の私のコードです。私は視覚化のためにミキサーを使用します。フォルダからすべてのファイルを読み込んで読み込むPython
import bpy # This module gives access to blender data, classes, and functions
import os # This module provides a unified interface to a number of operating system functions.
import sys # This module provides a number of functions and variables that can be used to manipulate different parts of the Python runtime environment.
path = "C:\\Users\\PC\\Desktop\\Rotate Prototype\\filtered"
dir = os.listdir("C:\\Users\\PC\\Desktop\\Rotate Prototype\\filtered")
files = 0
for files in dir:
if files.lower().endswith('.bvh'):
try:
bpy.ops.object.delete() # Deletes the cube
bpy.ops.import_anim.bvh(filepath="C:\\Users\\PC\\Desktop\\Rotate Prototype\\filtered\\pick_001_3_fil_Take_001.bvh", axis_forward='-Z', axis_up='Y', filter_glob="*.bvh", target='ARMATURE', global_scale=1.0, frame_start=1, use_fps_scale=False, update_scene_fps=False, update_scene_duration=False, use_cyclic=False, rotate_mode='NATIVE') # We import a bvh file with the appropriate settings
bpy.context.scene.render.fps = 72 # We configure the frame rate
bpy.ops.export_anim.bvh(filepath="C:\\Users\\PC\\Desktop\\Rotate Prototype\\trolled\\haha.bvh", check_existing=True, filter_glob="*.bvh", global_scale=1.0, frame_start=1, frame_end=1515, rotate_mode='XYZ', root_transform_only=True) # We export the file with the appropriate settings
except:
print ("Couldn't open file")
files++
私はファイル++が有効なpythonコードではないと思います。 – mattsap
あなたの質問は何ですか?エラーが発生している場合は、エラーを出力してください。 – mattsap
'ファイル++ 'は何をすると思いますか?インポートされたファイルを数えている場合は、try節で字下げする必要があります。とにかくpythonは '++ '演算子が' files + = 1'を使うことを許可していません –