I don't know this is so damn hard but after:
bpy.ops.import_scene.obj(filepath=output_filepath)
How should I move the imported object, assuming I want to move it to the same location as the previously active object.
I just need a minimal example, the imported object should be selected but not active, I tested this to work in console:
bpy.context.selected_objects[0].location = bpy.context.active_object.location
But it doesn't work in addon script, I don't know why.
Replies
Damn, Blender doesn't refresh your addon when you modified it and install it again? (modified it as a separate file of course, not trying to change it in addon directory, knowing that caching will mess with me.)
Do I have to delete its addon cache (pyc file) and restart Blender for changes to take effect?
You open the installed add-on script(s), change them, and to reload it with the new code you will untick + retick the add-on checkbox in the Add-ons tab of User Preferences. If you check the system console you'll see a "module changed on disk: [path to your addon]" message, meaning it reloads the add-on and runs the register() function again.
If you import some object / scene, it may change the active object. I would try doing what you want in three steps:
You'd need to change their default values to what you want, even if momentarily.