Created
March 17, 2015 16:31
-
-
Save lab1092/b1b732e3a92fe1ce8e14 to your computer and use it in GitHub Desktop.
OBJファイルを自動的にインポートした状態でBlenderを開く、の続き
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c:\blender\blender.exe -P C:\Users\username\desktop\testconv.py -b -- %1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on main(input) | |
try | |
do shell script "/Applications/Blender274RC1/blender.app/Contents/MacOS/blender -P ~/Desktop/testconv.py -b --" & space & input | |
end try | |
end main | |
on open argv | |
repeat with aFile in argv | |
main(quoted form of POSIX path of aFile) | |
end repeat | |
end open | |
on run | |
main(quoted form of POSIX path of (choose file)) | |
end run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import sys | |
import os | |
def delete_all(): | |
for item in bpy.context.scene.objects: | |
bpy.context.scene.objects.unlink(item) | |
for item in bpy.data.objects: | |
bpy.data.objects.remove(item) | |
for item in bpy.data.meshes: | |
bpy.data.meshes.remove(item) | |
for item in bpy.data.materials: | |
bpy.data.materials.remove(item) | |
def convert_file(filepath): | |
basename = filename = fileext = ext = outpath ='' | |
dirname = os.path.dirname(filepath) | |
basename = os.path.basename(filepath) | |
(filename,fileext) = os.path.splitext(basename) | |
ext = fileext.lower() | |
if os.path.isfile(filepath): | |
# .obj -> .fbx | |
if ext =='.obj': | |
bpy.ops.import_scene.obj(filepath=filepath) | |
outpath = os.path.join(dirname,filename+".fbx") | |
bpy.ops.export_scene.fbx(filepath=outpath) | |
else: | |
None | |
if __name__ == "__main__": | |
delete_all() | |
convert_file(filepath=sys.argv[-1]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment