How to panning of view3D by Python api in Blender 3D.

I would like to panning of 3D view port by Python API in blender 3D.

So, i did search a command in manual.
And i found command such as “bpy.ops.view3D.ndof_pan()”.
But i don’t know how to use it’s command.
Perhaps, do you know how to use it?

My code : http://shshop.da.to/tmp/go_pan.py

Please answer to me.

Thank you.

The easist way is to use the view_pan operator on the view3d region:

for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        bpy.ops.view3d.view_pan({'area': area, 'region': area.regions[-1]}, type='PANUP')
        break

buttons for a panel (view3d tools sidebar, no override / EXEC_REGION_WIN needed 'cause it’s the right area):

import bpy

class NoOperation(bpy.types.Operator):
    bl_idname = "view3d.noop"
    bl_label = ""

    def execute(self, context):
        return {'FINISHED'}


class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Layout Demo"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    #bl_context = "scene"

    def draw(self, context):
        layout = self.layout
        
        col = layout.column(True)
        sub = col.row(True)
        sub.operator("view3d.noop", icon='BLANK1', emboss=False)
        sub.operator("view3d.view_pan", text="", icon='TRIA_UP').type = 'PANUP'
        sub.operator("view3d.noop", icon='BLANK1', emboss=False)
        sub = col.row(True)
        sub.scale_y = 1.2
        sub.operator("view3d.view_pan", text="", icon='TRIA_LEFT').type = 'PANLEFT'
        sub.operator("view3d.noop", icon='BLANK1', emboss=False)
        sub.operator("view3d.view_pan", text="", icon='TRIA_RIGHT').type = 'PANRIGHT'
        sub = col.row(True)
        sub.operator("view3d.noop", icon='BLANK1', emboss=False)
        sub.operator("view3d.view_pan", text="", icon='TRIA_DOWN').type = 'PANDOWN'
        sub.operator("view3d.noop", icon='BLANK1', emboss=False)
        

def register():
    bpy.utils.register_class(LayoutDemoPanel)
    bpy.utils.register_class(NoOperation)


def unregister():
    bpy.utils.unregister_class(LayoutDemoPanel)
    bpy.utils.unregister_class(NoOperation)


if __name__ == "__main__":
    register()


Thank you your reply.

But, i have one question.
Is it same ndof_pan() and view3d.view_pan() operator?

Please answer to me again.
Thank you.

No it’s not the same, ndof_* is for ndof devices

http://wiki.blender.org/index.php/Dev:Source/UI/Ndof_Devices

Thank you your reply.
You have been very helpful to me.
Thank you.