问题
The (probably not so well written) question is: Is there any way to get object data right after it is loaded through bpy.import_scene.obj function?
I mean when i import an obj file with this function i need to make some more transformation for it. When i select an object via name 'Mesh' (default name of object after import) all those functions works for other objects named 'Mesh' in my scene. I tried to get an last object from objects list in scene but they're arranged alphabeticaly, so it didn't worked well. When i tried to change object.name and apply next functions to it, it works only for one. All earlier instances of imported object are back to default.
How to solve that problem? Is there a option to get from scene last added object? Or maybe some way to 'mark' *obj object right after it is imported before next functions are applied? Or maybe there is a way to import *obj data straight into created earlier blank object.
cheers, regg
PS: Working on Blender 2.63
回答1:
Operators don't return data they load, but you can use tagging this way...
for obj in bpy.data.objects:
obj.tag = True
bpy.import_scene.obj(filepath="somefile.obj")
imported_objects = [obj for obj in bpy.data.objects if obj.tag is False]
回答2:
From what I saw after importing things, the default tag is true for all objects (including those who already exist in the scene). So it seems like that in order to mark objects, you have to assign them a false value, and then import, and then add them to imported objects if their tag is True. No the other way around. So I'm not sure this answer is accurate.
来源:https://stackoverflow.com/questions/14147287/how-to-mark-last-imported-obj-in-blender