I want to select an imported object and move it to a specific location. The object is imported in an earlier part of the script. After the import i move it with the following part of the script.
import bpy # Select object i want to move bpy.data.objects["Cube"].select = True # Move Origin to geometry and move object to location bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') bpy.context.object.location = 0 bpy.context.object.location = 0 bpy.context.object.location = 0 bpy.context.object.rotation_euler = 0 bpy.context.object.rotation_euler = 0 bpy.context.object.rotation_euler = 0
When the script is on position
bpy.context.object.location = 0 console gives following error:
Traceback (most recent call last): File "<blender_console>", line 1, in <module> AttributeError: 'NoneType' object has no attribute 'location'
I understand the message, that my Cube has no location attributes. But he must have them. When i select him with right mouse and type
bpy.context.object.location = 0, no error is given and he moves to the position i want.
Do i have an error in the selection-part of my script? How can i solve this?