1 # 3D NAVIGATION TOOLBAR v1.2 - 3Dview Addon - Blender 2.5x
3 # THIS SCRIPT IS LICENSED UNDER GPL,
4 # please read the license block.
6 # ##### BEGIN GPL LICENSE BLOCK #####
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software Foundation,
20 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 # ##### END GPL LICENSE BLOCK #####
23 # contributed to by: Demohero, uriel, jbelcik, meta-androcto
26 "name": "3D Navigation",
27 "author": "Demohero, uriel",
29 "blender": (2, 92, 0),
30 "location": "View3D > Sidebar > View Tab",
31 "description": "Navigate the Camera & 3D Viewport from the Sidebar",
33 "doc_url": "{BLENDER_MANUAL_URL}/addons/3d_view/3d_navigation.html",
34 "category": "3D View",
38 from bpy
.types
import (
43 from bpy
.props
import StringProperty
46 # main class of this toolbar
48 # re-ordered (reversed) Orbit Operators
49 class VIEW3D_OT_OrbitUpView1(Operator
):
50 bl_idname
= "opr.orbit_up_view1"
51 bl_label
= "Orbit Up View"
52 bl_description
= "Orbit the view towards you"
54 def execute(self
, context
):
55 bpy
.ops
.view3d
.view_orbit(type='ORBITUP')
59 class VIEW3D_OT_OrbitLeftView1(Operator
):
60 bl_idname
= "opr.orbit_left_view1"
61 bl_label
= "Orbit Left View"
62 bl_description
= "Orbit the view around to your Right"
64 def execute(self
, context
):
65 bpy
.ops
.view3d
.view_orbit(type='ORBITLEFT')
69 class VIEW3D_OT_OrbitRightView1(Operator
):
70 bl_idname
= "opr.orbit_right_view1"
71 bl_label
= "Orbit Right View"
72 bl_description
= "Orbit the view around to your Left"
74 def execute(self
, context
):
75 bpy
.ops
.view3d
.view_orbit(type='ORBITRIGHT')
79 class VIEW3D_OT_OrbitDownView1(Operator
):
80 bl_idname
= "opr.orbit_down_view1"
81 bl_label
= "Orbit Down View"
82 bl_description
= "Orbit the view away from you"
84 def execute(self
, context
):
85 bpy
.ops
.view3d
.view_orbit(type='ORBITDOWN')
89 # re-ordered (reversed) Pan Operators
90 # just pass the enum from the VIEW3D_PT_pan_navigation1 Panel
91 class VIEW3D_OT_PanUpViewsAll(Operator
):
92 bl_idname
= "opr.pan_up_views_all"
94 bl_description
= "Pan the 3D View"
96 panning
: StringProperty(
101 def execute(self
, context
):
103 bpy
.ops
.view3d
.view_pan("INVOKE_REGION_WIN", type=self
.panning
)
104 except Exception as e
:
105 self
.report({"WARNING"},
106 "Pan Views could not be completed. Operation Cancelled")
107 print("\n[3D Navigation]\nOperator: opr.pan_up_views_all\n {}\n".format(e
))
115 class VIEW3D_OT_ZoomInView1(Operator
):
116 bl_idname
= "opr.zoom_in_view1"
117 bl_label
= "Zoom In View"
118 bl_description
= "Zoom In the View/Camera View"
120 def execute(self
, context
):
121 bpy
.ops
.view3d
.zoom(delta
=1)
125 class VIEW3D_OT_ZoomOutView1(Operator
):
126 bl_idname
= "opr.zoom_out_view1"
127 bl_label
= "Zoom Out View"
128 bl_description
= "Zoom out In the View/Camera View"
130 def execute(self
, context
):
131 bpy
.ops
.view3d
.zoom(delta
=-1)
136 class VIEW3D_OT_RollLeftView1(Operator
):
137 bl_idname
= "opr.roll_left_view1"
138 bl_label
= "Roll Left View"
139 bl_description
= "Roll the view Left"
141 def execute(self
, context
):
142 bpy
.ops
.view3d
.view_roll(angle
=-0.261799)
146 class VIEW3D_OT_RollRightView1(Operator
):
147 bl_idname
= "opr.roll_right_view1"
148 bl_label
= "Roll Right View"
149 bl_description
= "Roll the view Right"
151 def execute(self
, context
):
152 bpy
.ops
.view3d
.view_roll(angle
=0.261799)
157 class VIEW3D_OT_LeftViewpoint1(Operator
):
158 bl_idname
= "opr.left_viewpoint1"
159 bl_label
= "Left Viewpoint"
160 bl_description
= "View from the Left"
162 def execute(self
, context
):
163 bpy
.ops
.view3d
.view_axis(type='LEFT')
167 class VIEW3D_OT_RightViewpoint1(Operator
):
168 bl_idname
= "opr.right_viewpoint1"
169 bl_label
= "Right Viewpoint"
170 bl_description
= "View from the Right"
172 def execute(self
, context
):
173 bpy
.ops
.view3d
.view_axis(type='RIGHT')
177 class VIEW3D_OT_FrontViewpoint1(Operator
):
178 bl_idname
= "opr.front_viewpoint1"
179 bl_label
= "Front Viewpoint"
180 bl_description
= "View from the Front"
182 def execute(self
, context
):
183 bpy
.ops
.view3d
.view_axis(type='FRONT')
187 class VIEW3D_OT_BackViewpoint1(Operator
):
188 bl_idname
= "opr.back_viewpoint1"
189 bl_label
= "Back Viewpoint"
190 bl_description
= "View from the Back"
192 def execute(self
, context
):
193 bpy
.ops
.view3d
.view_axis(type='BACK')
197 class VIEW3D_OT_TopViewpoint1(Operator
):
198 bl_idname
= "opr.top_viewpoint1"
199 bl_label
= "Top Viewpoint"
200 bl_description
= "View from the Top"
202 def execute(self
, context
):
203 bpy
.ops
.view3d
.view_axis(type='TOP')
207 class VIEW3D_OT_BottomViewpoint1(Operator
):
208 bl_idname
= "opr.bottom_viewpoint1"
209 bl_label
= "Bottom Viewpoint"
210 bl_description
= "View from the Bottom"
212 def execute(self
, context
):
213 bpy
.ops
.view3d
.view_axis(type='BOTTOM')
217 # Panel class of this toolbar
218 class VIEW3D_PT_3dnavigationPanel(Panel
):
219 bl_space_type
= "VIEW_3D"
220 bl_region_type
= "UI"
221 bl_label
= "3D Navigation"
223 bl_options
= {'DEFAULT_CLOSED'}
225 def draw(self
, context
):
227 view
= context
.space_data
230 col
= layout
.column(align
=True)
231 col
.operator("view3d.localview", text
="View Global/Local")
232 col
.operator("view3d.view_persportho", text
="Perspective/Orthographic")
233 col
.operator("view3d.view_camera", text
="View Camera", icon
='CAMERA_DATA')
236 col
= layout
.column(align
=True)
237 col
.label(text
="Align view from:", icon
="VIEW3D")
239 row
.operator("view3d.view_axis", text
="Front").type = 'FRONT'
240 row
.operator("view3d.view_axis", text
="Back").type = 'BACK'
242 row
.operator("view3d.view_axis", text
="Left").type = 'LEFT'
243 row
.operator("view3d.view_axis", text
="Right").type = 'RIGHT'
245 row
.operator("view3d.view_axis", text
="Top").type = 'TOP'
246 row
.operator("view3d.view_axis", text
="Bottom").type = 'BOTTOM'
249 col
= layout
.column(align
=True)
250 col
.label(text
="Lock View to Object:", icon
="LOCKED")
251 col
.prop(view
, "lock_object", text
="")
252 col
.operator("view3d.view_selected", text
="View to Selected")
254 col
= layout
.column(align
=True)
255 col
.label(text
="Cursor:", icon
='PIVOT_CURSOR')
256 row
= col
.row(align
=True)
257 row
.operator("view3d.snap_cursor_to_center", text
="World Origin")
258 row
.operator("view3d.view_center_cursor", text
="View")
259 col
.operator("view3d.snap_cursor_to_selected", text
="Cursor to Selected")
262 class VIEW3D_PT_3dnavigationPanel2(Panel
):
263 bl_space_type
= "VIEW_3D"
264 bl_region_type
= "UI"
265 bl_label
= "Pan Orbit Zoom Roll"
267 bl_options
= {'DEFAULT_CLOSED'}
269 def draw(self
, context
):
271 layout
.label(text
="Screen View Perspective")
274 row
.label(text
="Pan:")
277 row
.operator("opr.pan_up_views_all", text
="Up",
278 icon
="TRIA_UP").panning
= "PANDOWN"
279 row
.operator("opr.pan_up_views_all", text
="Down",
280 icon
="TRIA_DOWN").panning
= "PANUP"
283 row
.operator("opr.pan_up_views_all", text
="Left",
284 icon
="BACK").panning
= "PANRIGHT"
285 row
.operator("opr.pan_up_views_all", text
="Right",
286 icon
="FORWARD").panning
= "PANLEFT"
289 row
.label(text
="Orbit:")
291 row
.operator("opr.orbit_down_view1", text
="Up", icon
="TRIA_UP")
292 row
.operator("opr.orbit_up_view1", text
="Down", icon
="TRIA_DOWN")
295 row
.operator("opr.orbit_right_view1", text
="Left", icon
="BACK")
296 row
.operator("opr.orbit_left_view1", text
="Right", icon
="FORWARD")
299 row
.label(text
="Zoom:")
301 row
.operator("opr.zoom_in_view1", text
="In", icon
='ADD')
302 row
.operator("opr.zoom_out_view1", text
="Out", icon
='REMOVE')
305 row
.label(text
="Roll:")
307 row
.operator("opr.roll_left_view1", text
="Left", icon
="LOOP_BACK")
308 row
.operator("opr.roll_right_view1", text
="Right", icon
="LOOP_FORWARDS")
311 # Add-ons Preferences Update Panel
313 # Define Panel classes for updating
315 VIEW3D_PT_3dnavigationPanel
,
316 VIEW3D_PT_3dnavigationPanel2
,
320 def update_panel(self
, context
):
321 message
= ": Updating Panel locations has failed"
324 if "bl_rna" in panel
.__dict
__:
325 bpy
.utils
.unregister_class(panel
)
328 panel
.bl_category
= context
.preferences
.addons
[__name__
].preferences
.category
329 bpy
.utils
.register_class(panel
)
331 except Exception as e
:
332 print("\n[{}]\n{}\n\nError:\n{}".format(__name__
, message
, e
))
336 class NavAddonPreferences(AddonPreferences
):
337 # this must match the addon name, use '__package__'
338 # when defining this in a submodule of a python package.
341 category
: StringProperty(
343 description
="Choose a name for the category of the panel",
348 def draw(self
, context
):
353 col
.label(text
="Tab Category:")
354 col
.prop(self
, "category", text
="")
358 VIEW3D_PT_3dnavigationPanel
,
359 VIEW3D_PT_3dnavigationPanel2
,
360 VIEW3D_OT_OrbitUpView1
,
361 VIEW3D_OT_OrbitLeftView1
,
362 VIEW3D_OT_OrbitRightView1
,
363 VIEW3D_OT_OrbitDownView1
,
364 VIEW3D_OT_ZoomInView1
,
365 VIEW3D_OT_ZoomOutView1
,
366 VIEW3D_OT_RollLeftView1
,
367 VIEW3D_OT_RollRightView1
,
368 VIEW3D_OT_LeftViewpoint1
,
369 VIEW3D_OT_RightViewpoint1
,
370 VIEW3D_OT_FrontViewpoint1
,
371 VIEW3D_OT_BackViewpoint1
,
372 VIEW3D_OT_TopViewpoint1
,
373 VIEW3D_OT_BottomViewpoint1
,
374 VIEW3D_OT_PanUpViewsAll
,
382 bpy
.utils
.register_class(cls
)
383 update_panel(None, bpy
.context
)
388 bpy
.utils
.unregister_class(cls
)
391 if __name__
== "__main__":