[X3D-Ecosystem] Blender Python for ortho, positive z out of screen.

John Carlson yottzumm at gmail.com
Sat Jun 29 11:51:03 PDT 2024


This doesn't hit all views yet.  Additions welcome!

Joe pressured me to make blender "X3D-like," so here's a script you can
use. It doesn't work too well yet, and I've not tested it in the GUI.

def set_view_to_positive_z():
    # Get the 3D view area
    # area = next(area for area in bpy.context.screen.areas if area.type ==
'VIEW_3D')
    for area in bpy.context.screen.areas:
        # Get the 3D view space
        #space = area.spaces.active
        for space in area.spaces:

            # Turn off the grid floor
            # space.overlay.show_floor = False

            # If you also want to turn off the axes
            #space.overlay.show_axis_x = False
            #space.overlay.show_axis_y = False
            #space.overlay.show_axis_z = False

            if hasattr(space, "region_3d"):
                # Set the view to orthographic
                space.region_3d.view_perspective = 'ORTHO'

                # Set the view rotation
                rotation = Euler((0, 0, 0), 'XYZ')  # no rotation
                space.region_3d.view_rotation = rotation.to_quaternion()

                # Optionally, you can set the view distance
                space.region_3d.view_distance = 10

    # Update the view
    bpy.context.view_layer.update()

# Call the function to set the view
set_view_to_positive_z()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-ecosystem_web3d.org/attachments/20240629/79c2b541/attachment.html>


More information about the X3D-Ecosystem mailing list