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, 77, 0),
30 "location": "View3D > Tool Shelf > Display Tab",
31 "description": "Navigate the Camera & 3D View from the Toolshelf",
33 "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
34 "Scripts/3D_interaction/3D_Navigation",
35 "category": "3D View",
39 from bpy
.types
import (
44 from bpy
.props
import StringProperty
47 # main class of this toolbar
49 # re-ordered (reversed) Orbit Operators
50 class OrbitUpView1(Operator
):
51 bl_idname
= "opr.orbit_up_view1"
52 bl_label
= "Orbit Up View"
53 bl_description
= "Orbit the view towards you"
55 def execute(self
, context
):
56 bpy
.ops
.view3d
.view_orbit(type='ORBITUP')
60 class OrbitLeftView1(Operator
):
61 bl_idname
= "opr.orbit_left_view1"
62 bl_label
= "Orbit Left View"
63 bl_description
= "Orbit the view around to your Right"
65 def execute(self
, context
):
66 bpy
.ops
.view3d
.view_orbit(type='ORBITLEFT')
70 class OrbitRightView1(Operator
):
71 bl_idname
= "opr.orbit_right_view1"
72 bl_label
= "Orbit Right View"
73 bl_description
= "Orbit the view around to your Left"
75 def execute(self
, context
):
76 bpy
.ops
.view3d
.view_orbit(type='ORBITRIGHT')
80 class OrbitDownView1(Operator
):
81 bl_idname
= "opr.orbit_down_view1"
82 bl_label
= "Orbit Down View"
83 bl_description
= "Orbit the view away from you"
85 def execute(self
, context
):
86 bpy
.ops
.view3d
.view_orbit(type='ORBITDOWN')
90 # re-ordered (reversed) Pan Operators
91 # just pass the enum from the VIEW3D_PT_pan_navigation1 Panel
92 class PanUpViewsAll(Operator
):
93 bl_idname
= "opr.pan_up_views_all"
95 bl_description
= "Pan the 3D View"
97 panning
= StringProperty(
102 def execute(self
, context
):
104 bpy
.ops
.view3d
.view_pan("INVOKE_REGION_WIN", type=self
.panning
)
105 except Exception as e
:
106 self
.report({"WARNING"},
107 "Pan Views could not be completed. Operation Cancelled")
108 print("\n[3D Navigation]\nOperator: opr.pan_up_views_all\n {}\n".format(e
))
116 class ZoomInView1(Operator
):
117 bl_idname
= "opr.zoom_in_view1"
118 bl_label
= "Zoom In View"
119 bl_description
= "Zoom In the View/Camera View"
121 def execute(self
, context
):
122 bpy
.ops
.view3d
.zoom(delta
=1)
126 class ZoomOutView1(Operator
):
127 bl_idname
= "opr.zoom_out_view1"
128 bl_label
= "Zoom Out View"
129 bl_description
= "Zoom out In the View/Camera View"
131 def execute(self
, context
):
132 bpy
.ops
.view3d
.zoom(delta
=-1)
137 class RollLeftView1(Operator
):
138 bl_idname
= "opr.roll_left_view1"
139 bl_label
= "Roll Left View"
140 bl_description
= "Roll the view Left"
142 def execute(self
, context
):
143 bpy
.ops
.view3d
.view_roll(angle
=-0.261799)
147 class RollRightView1(Operator
):
148 bl_idname
= "opr.roll_right_view1"
149 bl_label
= "Roll Right View"
150 bl_description
= "Roll the view Right"
152 def execute(self
, context
):
153 bpy
.ops
.view3d
.view_roll(angle
=0.261799)
158 class LeftViewpoint1(Operator
):
159 bl_idname
= "opr.left_viewpoint1"
160 bl_label
= "Left Viewpoint"
161 bl_description
= "View from the Left"
163 def execute(self
, context
):
164 bpy
.ops
.view3d
.viewnumpad(type='LEFT')
168 class RightViewpoint1(Operator
):
169 bl_idname
= "opr.right_viewpoint1"
170 bl_label
= "Right Viewpoint"
171 bl_description
= "View from the Right"
173 def execute(self
, context
):
174 bpy
.ops
.view3d
.viewnumpad(type='RIGHT')
178 class FrontViewpoint1(Operator
):
179 bl_idname
= "opr.front_viewpoint1"
180 bl_label
= "Front Viewpoint"
181 bl_description
= "View from the Front"
183 def execute(self
, context
):
184 bpy
.ops
.view3d
.viewnumpad(type='FRONT')
188 class BackViewpoint1(Operator
):
189 bl_idname
= "opr.back_viewpoint1"
190 bl_label
= "Back Viewpoint"
191 bl_description
= "View from the Back"
193 def execute(self
, context
):
194 bpy
.ops
.view3d
.viewnumpad(type='BACK')
198 class TopViewpoint1(Operator
):
199 bl_idname
= "opr.top_viewpoint1"
200 bl_label
= "Top Viewpoint"
201 bl_description
= "View from the Top"
203 def execute(self
, context
):
204 bpy
.ops
.view3d
.viewnumpad(type='TOP')
208 class BottomViewpoint1(Operator
):
209 bl_idname
= "opr.bottom_viewpoint1"
210 bl_label
= "Bottom Viewpoint"
211 bl_description
= "View from the Bottom"
213 def execute(self
, context
):
214 bpy
.ops
.view3d
.viewnumpad(type='BOTTOM')
218 # Panel class of this toolbar
219 class VIEW3D_PT_3dnavigationPanel(Panel
):
220 bl_category
= "Display"
221 bl_space_type
= "VIEW_3D"
222 bl_region_type
= "TOOLS"
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
="View Persp / Ortho")
233 col
.operator("view3d.viewnumpad", text
="View Camera", icon
='CAMERA_DATA').type = 'CAMERA'
236 col
= layout
.column(align
=True)
237 col
.label(text
="Align view from:", icon
="VIEW3D")
239 row
.operator("view3d.viewnumpad", text
="Front").type = 'FRONT'
240 row
.operator("view3d.viewnumpad", text
="Back").type = 'BACK'
242 row
.operator("view3d.viewnumpad", text
="Left").type = 'LEFT'
243 row
.operator("view3d.viewnumpad", text
="Right").type = 'RIGHT'
245 row
.operator("view3d.viewnumpad", text
="Top").type = 'TOP'
246 row
.operator("view3d.viewnumpad", 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
="CURSOR")
256 row
= col
.row(align
=True)
257 row
.operator("view3d.snap_cursor_to_center", text
="Center")
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_pan_navigation1(Panel
):
263 bl_idname
= "pan.navigation1"
264 bl_label
= "Pan Orbit Zoom Roll"
265 bl_space_type
= "VIEW_3D"
266 bl_region_type
= "TOOLS"
267 bl_category
= "Display"
268 bl_options
= {'DEFAULT_CLOSED'}
270 def draw(self
, context
):
272 layout
.label(text
="Screen View Perspective")
275 row
.label(text
="Pan:")
278 row
.operator("opr.pan_up_views_all", text
="Up",
279 icon
="TRIA_UP").panning
= "PANDOWN"
280 row
.operator("opr.pan_up_views_all", text
="Down",
281 icon
="TRIA_DOWN").panning
= "PANUP"
284 row
.operator("opr.pan_up_views_all", text
="Left",
285 icon
="BACK").panning
= "PANRIGHT"
286 row
.operator("opr.pan_up_views_all", text
="Right",
287 icon
="FORWARD").panning
= "PANLEFT"
290 row
.label(text
="Orbit:")
292 row
.operator("opr.orbit_down_view1", text
="Up", icon
="TRIA_UP")
293 row
.operator("opr.orbit_up_view1", text
="Down", icon
="TRIA_DOWN")
296 row
.operator("opr.orbit_right_view1", text
="Left", icon
="BACK")
297 row
.operator("opr.orbit_left_view1", text
="Right", icon
="FORWARD")
300 row
.label(text
="Zoom:")
302 row
.operator("opr.zoom_in_view1", text
="In", icon
="ZOOMIN")
303 row
.operator("opr.zoom_out_view1", text
="Out", icon
="ZOOMOUT")
306 row
.label(text
="Roll:")
308 row
.operator("opr.roll_left_view1", text
="Left", icon
="LOOP_BACK")
309 row
.operator("opr.roll_right_view1", text
="Right", icon
="LOOP_FORWARDS")
312 # Add-ons Preferences Update Panel
314 # Define Panel classes for updating
316 VIEW3D_PT_3dnavigationPanel
,
317 VIEW3D_PT_pan_navigation1
,
321 def update_panel(self
, context
):
322 message
= ": Updating Panel locations has failed"
325 if "bl_rna" in panel
.__dict
__:
326 bpy
.utils
.unregister_class(panel
)
329 panel
.bl_category
= context
.user_preferences
.addons
[__name__
].preferences
.category
330 bpy
.utils
.register_class(panel
)
332 except Exception as e
:
333 print("\n[{}]\n{}\n\nError:\n{}".format(__name__
, message
, e
))
337 class NavAddonPreferences(AddonPreferences
):
338 # this must match the addon name, use '__package__'
339 # when defining this in a submodule of a python package.
342 category
= StringProperty(
344 description
="Choose a name for the category of the panel",
349 def draw(self
, context
):
354 col
.label(text
="Tab Category:")
355 col
.prop(self
, "category", text
="")
359 VIEW3D_PT_3dnavigationPanel
,
360 VIEW3D_PT_pan_navigation1
,
383 bpy
.utils
.register_class(cls
)
384 update_panel(None, bpy
.context
)
389 bpy
.utils
.unregister_class(cls
)
392 if __name__
== "__main__":