Blender 控制台:使用 threejs 导出器导出单个网格
Blender console: export single mesh using threejs exporter
我正在使用 Blender 2.76b,threejs exporter v1.5.0;我的目标是导出 Blender 场景中的每个网格。我注意到如果选择了单个网格,io_three 会导出该网格,所以我在控制台中编写了一个简单的 python 可执行脚本:
import bpy
for ob in bpy.context.scene.objects:
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.object.select_pattern(pattern = ob.name)
bpy.ops.export.three(
filepath = 'path to folder' + ob.name + ".json",
option_vertices=True,
option_faces=True,
option_normals=True,
option_uv_coords=True,
option_face_materials=True,
option_colors=True)
它创建的文件名称正确,但内容错误:所有 .json 文件都包含场景第一个网格的导出内容。
我怎样才能得到正确的行为?
提前致谢。
three.js 导出器导出整个场景或活动对象。当您更改选择时,脚本中的任何内容都不会更改活动对象。我使用的 abspath()
允许您通过以 '//'
开头的路径来获取相对于 blend 文件的路径
import bpy
for ob in bpy.context.scene.objects:
bpy.ops.object.select_all(action='DESELECT')
if ob.type == 'MESH':
ob.select = True
bpy.context.scene.objects.active = ob
bpy.ops.export.three(
filepath = bpy.path.abspath('//' + ob.name + ".json"),
option_vertices=True,
option_faces=True,
option_normals=True,
option_uv_coords=True,
option_face_materials=True,
option_colors=True)
我正在使用 Blender 2.76b,threejs exporter v1.5.0;我的目标是导出 Blender 场景中的每个网格。我注意到如果选择了单个网格,io_three 会导出该网格,所以我在控制台中编写了一个简单的 python 可执行脚本:
import bpy
for ob in bpy.context.scene.objects:
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.object.select_pattern(pattern = ob.name)
bpy.ops.export.three(
filepath = 'path to folder' + ob.name + ".json",
option_vertices=True,
option_faces=True,
option_normals=True,
option_uv_coords=True,
option_face_materials=True,
option_colors=True)
它创建的文件名称正确,但内容错误:所有 .json 文件都包含场景第一个网格的导出内容。
我怎样才能得到正确的行为? 提前致谢。
three.js 导出器导出整个场景或活动对象。当您更改选择时,脚本中的任何内容都不会更改活动对象。我使用的 abspath()
允许您通过以 '//'
import bpy
for ob in bpy.context.scene.objects:
bpy.ops.object.select_all(action='DESELECT')
if ob.type == 'MESH':
ob.select = True
bpy.context.scene.objects.active = ob
bpy.ops.export.three(
filepath = bpy.path.abspath('//' + ob.name + ".json"),
option_vertices=True,
option_faces=True,
option_normals=True,
option_uv_coords=True,
option_face_materials=True,
option_colors=True)