I'm trying to run this script in a Blender text editor:
import bpy
object_dir = "/somedir"
object_all = bpy.context.scene.objects
for ob in object_all:
if ob.hide == True:
object_name = ob.name
#print(object_name)
#data_blocks = set(bpy.data.objects[object_name])
data_blocks = set(ob)
but when I do I get "TypeError: 'Object' object is not iterable".
What's the correct way to access a bpy.data.object thru a bpy.context? Thanks in advance.
Alright, I was a bit vague. Here's the code:
import bpy
object_dir = "/Users/max/Developer/Content/3D/objects/"
object_all = bpy.context.scene.objects
for ob in object_all:
if ob.hide == True:
object_name = ob.name
print(object_name)
data_blocks = set(bpy.data.objects[object_name])
bpy.data.libraries.write(
object_dir + "_" + object_name + ".blend",
data_blocks,
relative_remap = True
)
bpy.ops.export_scene.obj(
filepath = object_dir + "_" + object_name + ".obj",
use_selection = True,
use_mesh_modifiers = True,
use_materials = False
)
what I want to do is simply write to a library and export to obj every hidden object I have. The error:
line 12, in TypeError: 'Object' object is not iterable Error: Python script fail, look in the console for now...
error is referred to this line:
data_blocks = set(bpy.data.objects[object_name])
Thanks again.