【问题标题】:Blender console: export single mesh using threejs exporterBlender 控制台:使用 threejs 导出器导出单个网格
【发布时间】:2016-10-23 11:32:52
【问题描述】:

我使用的是 Blender 2.76b,threejs 导出器 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 blender


    【解决方案1】:

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-11
      • 2017-07-30
      • 1970-01-01
      • 2019-05-27
      • 2018-09-14
      • 2013-04-05
      • 2015-01-12
      • 2017-10-07
      相关资源
      最近更新 更多