1
$\begingroup$

I'm trying to export each selected object, but it tells me that objects cannot be iterated.

import bpy
import pathlib
from pathlib import Path
from io_export_o3d.exporter import Exporter

context = bpy.context
objects = bpy.context.selected_objects
exporter = Exporter()

for ob in objects:
    context.view_layer.objects.active = ob
    Path = pathlib.WindowsPath('D:/Users/user/Downloads/3D Object Converter/models/export/atr11\\') / (ob.name + '.o3d')
    ob.select_set(True)
    if ob.type == 'MESH':
        exporter.export(ob, Path)
        ob.select_set(False)

This is the exporter class used:
https://github.com/Road-hog123/Blender-OMSI-Exporter

This is the error:

Error: Python: Traceback (most recent call last):
  File "D:\Users\user\Downloads\3D Object Converter\models\2302\untitled.blend\Text", line 16, in <module>
  File "C:\Users\sor ji\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\io_export_o3d\exporter.py", line 291, in export
    mesh.triangles = [meshio.Triangle(vs, m) for vs, m in triangles()]
  File "C:\Users\sor ji\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\io_export_o3d\exporter.py", line 291, in <listcomp>
    mesh.triangles = [meshio.Triangle(vs, m) for vs, m in triangles()]
  File "C:\Users\sor ji\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\io_export_o3d\exporter.py", line 214, in triangles
    for me, slots, vertex_groups in meshes():
  File "C:\Users\sor ji\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\io_export_o3d\exporter.py", line 145, in meshes
    for obj in self.filter_objects(objects):
  File "C:\Users\sor ji\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\io_export_o3d\exporter.py", line 109, in filter_objects
    return [o for o in objects if o.type == 'MESH']
TypeError: 'Object' object is not iterable
New contributor
Poehler Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
1
  • 1
    $\begingroup$ exporter.export is expecting a Iterable[Object] as its first argument, not an Object. Either pass all your objects at once or use [ob] to export one. $\endgroup$
    – scurest
    Nov 23 at 17:12

0

Your Answer

Poehler Lee is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.