0
$\begingroup$

Here is the code I am using (in a python script):

for obj in bpy.context.scene.objects:
    obj.select_set(False)

for obj in bpy.context.visible_objects:
    if not (obj.hide_get()):
        obj.select_set(True)

bpy.ops.view3d.camera_to_view_selected()

bpy.context.scene.render.filepath += "image"
bpy.ops.render.render(write_still=True)

Which produces this result: This image is too focused on the head

But if I manually go into blender and paste the code in, I get this result (excuse the textures/colors being messed up, I was just too lazy to manually adjust everything): This image renders correctly

Which is the result I was trying to get using the python script by itself. What am I doing wrong?

$\endgroup$
  • 1
    $\begingroup$ How are you calling / using the Python script in your first case? It works fine when bpy is imported first. $\endgroup$ – Robert Gützkow Dec 3 '19 at 20:22
  • $\begingroup$ Hello and welcome to the site! Could you please elaborate a bit and maybe explain what the script is supposed to do? And in what ways does the actual outcome differ from the expected one? That way one does not have to try and retrieve this information from the python script and images by themselves, but rather have the right idea of your question right away. $\endgroup$ – palkonimo Dec 3 '19 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.