1 # SPDX-FileCopyrightText: 2010-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # 3D NAVIGATION TOOLBAR v1.2 - 3Dview Addon - Blender 2.5x
6 # contributed to by: Demohero, uriel, jbelcik, meta-androcto
9 "name": "3D Navigation",
10 "author": "Demohero, uriel",
12 "blender": (2, 92, 0),
13 "location": "View3D > Sidebar > View Tab",
14 "description": "Navigate the Camera & 3D Viewport from the Sidebar",
16 "doc_url": "{BLENDER_MANUAL_URL}/addons/3d_view/3d_navigation.html",
17 "category": "3D View",
21 from bpy
.types
import (
26 from bpy
.props
import StringProperty
29 # main class of this toolbar
31 # re-ordered (reversed) Orbit Operators
32 class VIEW3D_OT_OrbitUpView1(Operator
):
33 bl_idname
= "opr.orbit_up_view1"
34 bl_label
= "Orbit Up View"
35 bl_description
= "Orbit the view towards you"
37 def execute(self
, context
):
38 bpy
.ops
.view3d
.view_orbit(type='ORBITUP')
42 class VIEW3D_OT_OrbitLeftView1(Operator
):
43 bl_idname
= "opr.orbit_left_view1"
44 bl_label
= "Orbit Left View"
45 bl_description
= "Orbit the view around to your Right"
47 def execute(self
, context
):
48 bpy
.ops
.view3d
.view_orbit(type='ORBITLEFT')
52 class VIEW3D_OT_OrbitRightView1(Operator
):
53 bl_idname
= "opr.orbit_right_view1"
54 bl_label
= "Orbit Right View"
55 bl_description
= "Orbit the view around to your Left"
57 def execute(self
, context
):
58 bpy
.ops
.view3d
.view_orbit(type='ORBITRIGHT')
62 class VIEW3D_OT_OrbitDownView1(Operator
):
63 bl_idname
= "opr.orbit_down_view1"
64 bl_label
= "Orbit Down View"
65 bl_description
= "Orbit the view away from you"
67 def execute(self
, context
):
68 bpy
.ops
.view3d
.view_orbit(type='ORBITDOWN')
72 # re-ordered (reversed) Pan Operators
73 # just pass the enum from the VIEW3D_PT_pan_navigation1 Panel
74 class VIEW3D_OT_PanUpViewsAll(Operator
):
75 bl_idname
= "opr.pan_up_views_all"
77 bl_description
= "Pan the 3D View"
79 panning
: StringProperty(
84 def execute(self
, context
):
86 bpy
.ops
.view3d
.view_pan("INVOKE_REGION_WIN", type=self
.panning
)
87 except Exception as e
:
88 self
.report({"WARNING"},
89 "Pan Views could not be completed. Operation Cancelled")
90 print("\n[3D Navigation]\nOperator: opr.pan_up_views_all\n {}\n".format(e
))
98 class VIEW3D_OT_ZoomInView1(Operator
):
99 bl_idname
= "opr.zoom_in_view1"
100 bl_label
= "Zoom In View"
101 bl_description
= "Zoom In the View/Camera View"
103 def execute(self
, context
):
104 bpy
.ops
.view3d
.zoom(delta
=1)
108 class VIEW3D_OT_ZoomOutView1(Operator
):
109 bl_idname
= "opr.zoom_out_view1"
110 bl_label
= "Zoom Out View"
111 bl_description
= "Zoom out In the View/Camera View"
113 def execute(self
, context
):
114 bpy
.ops
.view3d
.zoom(delta
=-1)
119 class VIEW3D_OT_RollLeftView1(Operator
):
120 bl_idname
= "opr.roll_left_view1"
121 bl_label
= "Roll Left View"
122 bl_description
= "Roll the view Left"
124 def execute(self
, context
):
125 bpy
.ops
.view3d
.view_roll(angle
=-0.261799)
129 class VIEW3D_OT_RollRightView1(Operator
):
130 bl_idname
= "opr.roll_right_view1"
131 bl_label
= "Roll Right View"
132 bl_description
= "Roll the view Right"
134 def execute(self
, context
):
135 bpy
.ops
.view3d
.view_roll(angle
=0.261799)
140 class VIEW3D_OT_LeftViewpoint1(Operator
):
141 bl_idname
= "opr.left_viewpoint1"
142 bl_label
= "Left Viewpoint"
143 bl_description
= "View from the Left"
145 def execute(self
, context
):
146 bpy
.ops
.view3d
.view_axis(type='LEFT')
150 class VIEW3D_OT_RightViewpoint1(Operator
):
151 bl_idname
= "opr.right_viewpoint1"
152 bl_label
= "Right Viewpoint"
153 bl_description
= "View from the Right"
155 def execute(self
, context
):
156 bpy
.ops
.view3d
.view_axis(type='RIGHT')
160 class VIEW3D_OT_FrontViewpoint1(Operator
):
161 bl_idname
= "opr.front_viewpoint1"
162 bl_label
= "Front Viewpoint"
163 bl_description
= "View from the Front"
165 def execute(self
, context
):
166 bpy
.ops
.view3d
.view_axis(type='FRONT')
170 class VIEW3D_OT_BackViewpoint1(Operator
):
171 bl_idname
= "opr.back_viewpoint1"
172 bl_label
= "Back Viewpoint"
173 bl_description
= "View from the Back"
175 def execute(self
, context
):
176 bpy
.ops
.view3d
.view_axis(type='BACK')
180 class VIEW3D_OT_TopViewpoint1(Operator
):
181 bl_idname
= "opr.top_viewpoint1"
182 bl_label
= "Top Viewpoint"
183 bl_description
= "View from the Top"
185 def execute(self
, context
):
186 bpy
.ops
.view3d
.view_axis(type='TOP')
190 class VIEW3D_OT_BottomViewpoint1(Operator
):
191 bl_idname
= "opr.bottom_viewpoint1"
192 bl_label
= "Bottom Viewpoint"
193 bl_description
= "View from the Bottom"
195 def execute(self
, context
):
196 bpy
.ops
.view3d
.view_axis(type='BOTTOM')
200 # Panel class of this toolbar
201 class VIEW3D_PT_3dnavigationPanel(Panel
):
202 bl_space_type
= "VIEW_3D"
203 bl_region_type
= "UI"
204 bl_label
= "3D Navigation"
206 bl_options
= {'DEFAULT_CLOSED'}
208 def draw(self
, context
):
210 view
= context
.space_data
213 col
= layout
.column(align
=True)
214 col
.operator("view3d.localview", text
="View Global/Local")
215 col
.operator("view3d.view_persportho", text
="Perspective/Orthographic")
216 col
.operator("view3d.view_camera", text
="View Camera", icon
='CAMERA_DATA')
219 col
= layout
.column(align
=True)
220 col
.label(text
="Align view from:", icon
="VIEW3D")
222 row
.operator("view3d.view_axis", text
="Front").type = 'FRONT'
223 row
.operator("view3d.view_axis", text
="Back").type = 'BACK'
225 row
.operator("view3d.view_axis", text
="Left").type = 'LEFT'
226 row
.operator("view3d.view_axis", text
="Right").type = 'RIGHT'
228 row
.operator("view3d.view_axis", text
="Top").type = 'TOP'
229 row
.operator("view3d.view_axis", text
="Bottom").type = 'BOTTOM'
232 col
= layout
.column(align
=True)
233 col
.label(text
="Lock View to Object:", icon
="LOCKED")
234 col
.prop(view
, "lock_object", text
="")
235 col
.operator("view3d.view_selected", text
="View to Selected")
237 col
= layout
.column(align
=True)
238 col
.label(text
="Cursor:", icon
='PIVOT_CURSOR')
239 row
= col
.row(align
=True)
240 row
.operator("view3d.snap_cursor_to_center", text
="World Origin")
241 row
.operator("view3d.view_center_cursor", text
="View")
242 col
.operator("view3d.snap_cursor_to_selected", text
="Cursor to Selected")
245 class VIEW3D_PT_3dnavigationPanel2(Panel
):
246 bl_space_type
= "VIEW_3D"
247 bl_region_type
= "UI"
248 bl_label
= "Pan Orbit Zoom Roll"
250 bl_options
= {'DEFAULT_CLOSED'}
252 def draw(self
, context
):
254 layout
.label(text
="Screen View Perspective")
257 row
.label(text
="Pan:")
260 row
.operator("opr.pan_up_views_all", text
="Up",
261 icon
="TRIA_UP").panning
= "PANDOWN"
262 row
.operator("opr.pan_up_views_all", text
="Down",
263 icon
="TRIA_DOWN").panning
= "PANUP"
266 row
.operator("opr.pan_up_views_all", text
="Left",
267 icon
="BACK").panning
= "PANRIGHT"
268 row
.operator("opr.pan_up_views_all", text
="Right",
269 icon
="FORWARD").panning
= "PANLEFT"
272 row
.label(text
="Orbit:")
274 row
.operator("opr.orbit_down_view1", text
="Up", icon
="TRIA_UP")
275 row
.operator("opr.orbit_up_view1", text
="Down", icon
="TRIA_DOWN")
278 row
.operator("opr.orbit_right_view1", text
="Left", icon
="BACK")
279 row
.operator("opr.orbit_left_view1", text
="Right", icon
="FORWARD")
282 row
.label(text
="Zoom:")
284 row
.operator("opr.zoom_in_view1", text
="In", icon
='ADD')
285 row
.operator("opr.zoom_out_view1", text
="Out", icon
='REMOVE')
288 row
.label(text
="Roll:")
290 row
.operator("opr.roll_left_view1", text
="Left", icon
="LOOP_BACK")
291 row
.operator("opr.roll_right_view1", text
="Right", icon
="LOOP_FORWARDS")
294 # Add-ons Preferences Update Panel
296 # Define Panel classes for updating
298 VIEW3D_PT_3dnavigationPanel
,
299 VIEW3D_PT_3dnavigationPanel2
,
303 def update_panel(self
, context
):
304 message
= ": Updating Panel locations has failed"
307 if "bl_rna" in panel
.__dict
__:
308 bpy
.utils
.unregister_class(panel
)
311 panel
.bl_category
= context
.preferences
.addons
[__name__
].preferences
.category
312 bpy
.utils
.register_class(panel
)
314 except Exception as e
:
315 print("\n[{}]\n{}\n\nError:\n{}".format(__name__
, message
, e
))
319 class NavAddonPreferences(AddonPreferences
):
320 # this must match the addon name, use '__package__'
321 # when defining this in a submodule of a python package.
324 category
: StringProperty(
326 description
="Choose a name for the category of the panel",
331 def draw(self
, context
):
336 col
.label(text
="Tab Category:")
337 col
.prop(self
, "category", text
="")
341 VIEW3D_PT_3dnavigationPanel
,
342 VIEW3D_PT_3dnavigationPanel2
,
343 VIEW3D_OT_OrbitUpView1
,
344 VIEW3D_OT_OrbitLeftView1
,
345 VIEW3D_OT_OrbitRightView1
,
346 VIEW3D_OT_OrbitDownView1
,
347 VIEW3D_OT_ZoomInView1
,
348 VIEW3D_OT_ZoomOutView1
,
349 VIEW3D_OT_RollLeftView1
,
350 VIEW3D_OT_RollRightView1
,
351 VIEW3D_OT_LeftViewpoint1
,
352 VIEW3D_OT_RightViewpoint1
,
353 VIEW3D_OT_FrontViewpoint1
,
354 VIEW3D_OT_BackViewpoint1
,
355 VIEW3D_OT_TopViewpoint1
,
356 VIEW3D_OT_BottomViewpoint1
,
357 VIEW3D_OT_PanUpViewsAll
,
365 bpy
.utils
.register_class(cls
)
366 update_panel(None, bpy
.context
)
371 bpy
.utils
.unregister_class(cls
)
374 if __name__
== "__main__":