안녕하세요 모두 저는 파이썬 초보자입니다. 내 코드에 문제가 있습니다. 특정 폴더에서 모든 .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++
필자는 파일 + +이 유효한 파이썬 코드라고 생각하지 않습니다. – mattsap
무엇이 당신의 질문입니까? 오류가 발생하면 출력에 오류를 표시하십시오. – mattsap
''파일 ++ ''은 무엇을할까요? 가져온 파일을 계산하는 경우 try 절에서 들여 쓰기되어야합니다. 어쨌든 파이썬은'++'연산자가'files + = 1'을 사용하도록 허용하지 않습니다. –