I am trying to write a script that will end up baking materials from a high poly object to a low poly object. The problem i am having is that i will never know the object names beforehand, as my script is importing obj's from a folder into blender then duplicating them and applying a decimate filter to them. So far i have all of that functioning correctly, but i'm stuck on the final part of selecting the low poly at the target object of the bake.
>>> bpy.ops.object.select_by_type(type='MESH')
{'FINISHED'}
>>>
>>> for obj in bpy.context.scene.objects:
... if obj.name.endswith("001"):
... print(ob.name)
... bpy.context.view_layer.objects.active = ob
...
Hat 1.001
>>>
I have the script printing out the name of the object that has a name ending in 001 since i know that my low poly duplicate will always end with that. My problem is that i need to take that printed name and apply it to the next command like this example
bpy.context.scene.targetobj = "Hat 1.001"
I can't figure out how to take the name that gets printed out and apply it like in that example. Thanks in advance.