4
$\begingroup$

I have Python scripts that generate shapes and every time I run the script I want Blender to zoom in to the new objects in my 3D view, automatically.

I know that you can select everything with the A or the following python snippet:

bpy.ops.object.select_all(action='TOGGLE')

The info view gives me this snippet.

enter image description here

I am working from a laptop so to toggle the perspective such that I can view everything that is selected I would press the \ button. How would I do this programmatically in Python? Also, why is the Python command for this not showing in the info view?

$\endgroup$
1
  • 2
    $\begingroup$ You can use bpy.ops.view3d.view_all() (equivalent of pressing the home key), but you'll have to override the context. $\endgroup$
    – gandalf3
    Commented Aug 16, 2014 at 9:04

1 Answer 1

4
$\begingroup$

To zoom into your new objects you will want to deselect all at the start of your script, then ensure that each new object is selected as it is added. You may want to keep a list of each new object then select them when done, depending on what steps you use this may be the only way to have only new objects selected as some methods can alter the selection.

Once you have the new objects selected you can use bpy.ops.view3d.view_selected() to zoom in on them.

The numpad / that you ask about is local view which is available as bpy.ops.view3d.localview()

As for the info window, I'm not certain of the exact criteria of what gets shown there as not everything shows. Most undoable actions and view changes show up, simple things like navigating the view don't. But then you can rename an object in the object properties and it shows but rename in the outliner and it doesn't.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .