Page MenuHome

view3d_tools.py

Authored By
koil (koilz)
Nov 13 2013, 5:19 PM
Size
24 KB
Subscribers
None

view3d_tools.py

# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "View 3D Icon Tools",
"author": "Koilz @ wiki.blender.org",
"version": (1, 0),
"blender": (2, 6, 6),
"location": "Editors > View 3D > Properties (N) > Tools",
"description": "Icon and small buttons which execute operators.",
"wiki_url": "http://wiki.blender.org/index.php/User:Koilz/13.03.06_View3D_Tools",
"category": "3D View"
}
import bpy
from bpy.types import Header, Menu, Panel
from bl_ui.properties_paint_common import UnifiedPaintPanel
""" ------------------------------------------------ """
""" Tools ------------------------------------------ """
class VIEW3D_PT_View3D_Tools(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Tools"
def draw(self, context):
layout = self.layout
scene = context.scene
active_object = context.active_object
""" ------------------------------------------------ """
""" Object Mode """
if bpy.context.mode=="OBJECT":
col = layout.column(align=True)
""" Objects """
""" View """
col = layout.column(align=True)
row = col.row(align=True)
row.operator("view3d.view_persportho",text="View")
row.operator("mesh.primitive_plane_add",icon='MESH_PLANE',text="")
row.operator("mesh.primitive_cube_add",icon='MESH_CUBE',text="")
row.operator("mesh.primitive_circle_add",icon='MESH_CIRCLE',text="")
row.operator("mesh.primitive_uv_sphere_add",icon='MESH_UVSPHERE',text="")
row.operator("mesh.primitive_ico_sphere_add",icon='MESH_ICOSPHERE',text="")
""" Origin """
row = col.row(align=True)
row.operator("object.origin_set", text="Origin")
row.operator("mesh.primitive_grid_add",icon='MESH_GRID',text="")
row.operator("mesh.primitive_monkey_add",icon='MESH_MONKEY',text="")
row.operator("mesh.primitive_cylinder_add",icon='MESH_CYLINDER',text="")
row.operator("mesh.primitive_torus_add",icon='MESH_TORUS',text="")
row.operator("mesh.primitive_cone_add",icon='MESH_CONE',text="")
""" Add Curve """
row = col.row(align=True)
row.operator("transform.translate",text="Locate")
row.operator("curve.primitive_bezier_curve_add",icon='CURVE_BEZCURVE',text="")
row.operator("curve.primitive_bezier_circle_add",icon='CURVE_BEZCIRCLE',text="")
row.operator("curve.primitive_nurbs_curve_add",icon='CURVE_NCURVE',text="")
row.operator("curve.primitive_nurbs_circle_add",icon='CURVE_NCIRCLE',text="")
row.operator("curve.primitive_nurbs_path_add",icon='CURVE_PATH',text="")
""" Add Surface """
row = col.row(align=True)
row.operator("transform.rotate")
row.operator("surface.primitive_nurbs_surface_circle_add",icon='SURFACE_NCIRCLE',text="")
row.operator("surface.primitive_nurbs_surface_surface_add",icon='SURFACE_NSURFACE',text="")
row.operator("surface.primitive_nurbs_surface_cylinder_add",icon='SURFACE_NCYLINDER',text="")
row.operator("surface.primitive_nurbs_surface_sphere_add",icon='SURFACE_NSPHERE',text="")
row.operator("surface.primitive_nurbs_surface_torus_add",icon='SURFACE_NTORUS',text="")
""" Add """
row = col.row(align=True)
row.operator("transform.resize", text="Scale")
row.operator("object.armature_add",text="",icon="BONE_DATA")
row.operator("object.add",text="",icon="OUTLINER_OB_LATTICE").type="LATTICE"
row.operator("object.speaker_add",icon='OUTLINER_OB_SPEAKER',text="")
row.operator("object.camera_add",icon='OUTLINER_OB_CAMERA',text="")
row.operator("object.lamp_add",icon='OUTLINER_OB_LAMP',text="")
""" -------- """
################
""" Object """
col = layout.column(align=True)
col.label(text="Object")
if active_object and active_object.type in {'MESH', 'CURVE', 'SURFACE'}:
row = col.row(align=True)
row.operator("object.shade_smooth", text="Smooth")
row.operator("object.shade_flat", text="Flat")
col.operator("object.duplicate_move",text="Duplicate")
col.operator("object.delete",text="Delete")
col.operator("object.join",text="Join")
""" Keyframes """
if active_object and active_object.type in {'MESH', 'CURVE', 'SURFACE', 'ARMATURE'}:
col = layout.column(align=True)
col.label(text="Keyframes (I) (Alt+I)")
row = col.row(align=True)
row.operator("anim.keyframe_insert_menu", icon='ZOOMIN', text="")
row.operator("anim.keyframe_delete_v3d", icon='ZOOMOUT', text="")
row.prop_search(scene.keying_sets_all, "active", scene, "keying_sets_all", text="")
row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
""" Motion """
col = layout.column(align=True)
col.label(text="Motion Paths")
row = col.row(align=True)
row.operator("object.paths_calculate", text="",icon="ANIM_DATA")
row.operator("object.paths_clear", text="",icon="PANEL_CLOSE")
""" Grease """
col = layout.column(align=True)
col.label(text="Grease")
row = col.row(align=True)
row.operator("gpencil.draw", text="",icon="GREASEPENCIL").mode = 'DRAW'
row.operator("gpencil.draw", text="",icon="OUTLINER_OB_CURVE").mode = 'DRAW_STRAIGHT'
row.operator("gpencil.draw", text="",icon="OUTLINER_OB_MESH").mode = 'DRAW_POLY'
row.operator("gpencil.draw", text="",icon="PANEL_CLOSE").mode = 'ERASER'
row.prop(context.tool_settings, "use_grease_pencil_sessions",text="Sketch")
""" ------------------------------------------------ """
""" ------------------------------------------------ """
""" Edit Mode Mesh """
if bpy.context.mode=="EDIT_MESH":
col = layout.column(align=True)
""" Objects """
""" View """
col = layout.column(align=True)
row = col.row(align=True)
row.operator("view3d.view_persportho",text="View")
row.operator("mesh.primitive_plane_add",icon='MESH_PLANE',text="")
row.operator("mesh.primitive_cube_add",icon='MESH_CUBE',text="")
row.operator("mesh.primitive_circle_add",icon='MESH_CIRCLE',text="")
row.operator("mesh.primitive_uv_sphere_add",icon='MESH_UVSPHERE',text="")
row.operator("mesh.primitive_ico_sphere_add",icon='MESH_ICOSPHERE',text="")
""" Origin """
row = col.row(align=True)
row.operator("object.origin_set", text="Origin")
row.operator("mesh.primitive_grid_add",icon='MESH_GRID',text="")
row.operator("mesh.primitive_monkey_add",icon='MESH_MONKEY',text="")
row.operator("mesh.primitive_cylinder_add",icon='MESH_CYLINDER',text="")
row.operator("mesh.primitive_torus_add",icon='MESH_TORUS',text="")
row.operator("mesh.primitive_cone_add",icon='MESH_CONE',text="")
""" Add Curve """
row = col.row(align=True)
row.operator("transform.translate",text="Locate")
row.operator("curve.primitive_bezier_curve_add",icon='CURVE_BEZCURVE',text="")
row.operator("curve.primitive_bezier_circle_add",icon='CURVE_BEZCIRCLE',text="")
row.operator("curve.primitive_nurbs_curve_add",icon='CURVE_NCURVE',text="")
row.operator("curve.primitive_nurbs_circle_add",icon='CURVE_NCIRCLE',text="")
row.operator("curve.primitive_nurbs_path_add",icon='CURVE_PATH',text="")
""" Add Surface """
row = col.row(align=True)
row.operator("transform.rotate")
row.operator("surface.primitive_nurbs_surface_circle_add",icon='SURFACE_NCIRCLE',text="")
row.operator("surface.primitive_nurbs_surface_surface_add",icon='SURFACE_NSURFACE',text="")
row.operator("surface.primitive_nurbs_surface_cylinder_add",icon='SURFACE_NCYLINDER',text="")
row.operator("surface.primitive_nurbs_surface_sphere_add",icon='SURFACE_NSPHERE',text="")
row.operator("surface.primitive_nurbs_surface_torus_add",icon='SURFACE_NTORUS',text="")
""" Add """
row = col.row(align=True)
row.operator("transform.resize", text="Scale")
row.operator("object.armature_add",text="",icon="BONE_DATA")
row.operator("object.add",text="",icon="OUTLINER_OB_LATTICE").type="LATTICE"
row.operator("object.speaker_add",icon='OUTLINER_OB_SPEAKER',text="")
row.operator("object.camera_add",icon='OUTLINER_OB_CAMERA',text="")
row.operator("object.lamp_add",icon='OUTLINER_OB_LAMP',text="")
""" -------- """
################
""" Mesh """
col = layout.column(align=True)
col.label(text="Mesh")
col.menu("VIEW3D_MT_edit_mesh_delete")
col.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude")
col.operator("mesh.duplicate_move",text="Duplicate")
col.operator("mesh.merge")
col = layout.column(align=True)
row = col.row(align=True)
row.operator("mesh.subdivide")
row.operator("mesh.unsubdivide")
row = col.row(align=True)
row.operator("mesh.loopcut_slide",text="Loop Cut")
row.operator("transform.edge_slide")
row = col.row(align=True)
props = row.operator("mesh.knife_tool", text="Knife All")
props.use_occlude_geometry = True
props.only_selected = False
props = row.operator("mesh.knife_tool", text="Knife Sel")
props.use_occlude_geometry = False
props.only_selected = True
row = col.row(align=True)
row.operator("mesh.edge_split")
row.operator("mesh.bridge_edge_loops",text="Edge Bridge")
row = col.row(align=True)
row.operator("mesh.rip_move")
row.operator("mesh.rip_move_fill")
row = col.row(align=True)
row.operator("mesh.split")
row.operator("mesh.separate")
row = col.row(align=True)
row.operator("mesh.edge_rotate",text="RE CW")
row.operator("mesh.edge_rotate",text="RE CCW").use_ccw=True
row = col.row(align=True)
row.operator("transform.edge_slide")
row.operator("mesh.vert_slide")
row = col.row(align=True)
row.operator("mesh.loop_multi_select",text="Edge Loop")
row.operator("mesh.loop_multi_select",text="Edge Ring").ring=True
row = col.row(align=True)
row.operator("mesh.normals_make_consistent", text="N Recalc")
row.operator("mesh.flip_normals", text="N Flip")
row = col.row(align=True)
row.operator("mesh.noise")
row.operator("mesh.vertices_smooth",text="Smooth")
row = col.row(align=True)
row.operator("mesh.quads_convert_to_tris",text="Quad to Tri")
row.operator("mesh.tris_convert_to_quads",text="Tri to Quad")
row = col.row(align=True)
row.operator("mesh.remove_doubles",text="Rem Doubles")
row.operator("mesh.symmetrize")
""" Motion """
col = layout.column(align=True)
col.label(text="Motion Paths")
row = col.row(align=True)
row.operator("object.paths_calculate", text="",icon="ANIM_DATA")
row.operator("object.paths_clear", text="",icon="PANEL_CLOSE")
""" Grease """
col = layout.column(align=True)
col.label(text="Grease")
row = col.row(align=True)
row.operator("gpencil.draw", text="",icon="GREASEPENCIL").mode = 'DRAW'
row.operator("gpencil.draw", text="",icon="OUTLINER_OB_CURVE").mode = 'DRAW_STRAIGHT'
row.operator("gpencil.draw", text="",icon="OUTLINER_OB_MESH").mode = 'DRAW_POLY'
row.operator("gpencil.draw", text="",icon="PANEL_CLOSE").mode = 'ERASER'
row.prop(context.tool_settings, "use_grease_pencil_sessions",text="Sketch")
""" ------------------------------------------------ """
""" ------------------------------------------------ """
""" Edit Mode Armature"""
if bpy.context.mode=="EDIT_ARMATURE":
col = layout.column(align=True)
""" Objects """
""" View """
col = layout.column(align=True)
row = col.row(align=True)
row.operator("view3d.view_persportho",text="View")
row.operator("mesh.primitive_plane_add",icon='MESH_PLANE',text="")
row.operator("mesh.primitive_cube_add",icon='MESH_CUBE',text="")
row.operator("mesh.primitive_circle_add",icon='MESH_CIRCLE',text="")
row.operator("mesh.primitive_uv_sphere_add",icon='MESH_UVSPHERE',text="")
row.operator("mesh.primitive_ico_sphere_add",icon='MESH_ICOSPHERE',text="")
""" Origin """
row = col.row(align=True)
row.operator("object.origin_set", text="Origin")
row.operator("mesh.primitive_grid_add",icon='MESH_GRID',text="")
row.operator("mesh.primitive_monkey_add",icon='MESH_MONKEY',text="")
row.operator("mesh.primitive_cylinder_add",icon='MESH_CYLINDER',text="")
row.operator("mesh.primitive_torus_add",icon='MESH_TORUS',text="")
row.operator("mesh.primitive_cone_add",icon='MESH_CONE',text="")
""" Add Curve """
row = col.row(align=True)
row.operator("transform.translate",text="Locate")
row.operator("curve.primitive_bezier_curve_add",icon='CURVE_BEZCURVE',text="")
row.operator("curve.primitive_bezier_circle_add",icon='CURVE_BEZCIRCLE',text="")
row.operator("curve.primitive_nurbs_curve_add",icon='CURVE_NCURVE',text="")
row.operator("curve.primitive_nurbs_circle_add",icon='CURVE_NCIRCLE',text="")
row.operator("curve.primitive_nurbs_path_add",icon='CURVE_PATH',text="")
""" Add Surface """
row = col.row(align=True)
row.operator("transform.rotate")
row.operator("surface.primitive_nurbs_surface_circle_add",icon='SURFACE_NCIRCLE',text="")
row.operator("surface.primitive_nurbs_surface_surface_add",icon='SURFACE_NSURFACE',text="")
row.operator("surface.primitive_nurbs_surface_cylinder_add",icon='SURFACE_NCYLINDER',text="")
row.operator("surface.primitive_nurbs_surface_sphere_add",icon='SURFACE_NSPHERE',text="")
row.operator("surface.primitive_nurbs_surface_torus_add",icon='SURFACE_NTORUS',text="")
""" Add """
row = col.row(align=True)
row.operator("transform.resize", text="Scale")
row.operator("object.armature_add",text="",icon="BONE_DATA")
row.operator("object.add",text="",icon="OUTLINER_OB_LATTICE").type="LATTICE"
row.operator("object.speaker_add",icon='OUTLINER_OB_SPEAKER',text="")
row.operator("object.camera_add",icon='OUTLINER_OB_CAMERA',text="")
row.operator("object.lamp_add",icon='OUTLINER_OB_LAMP',text="")
""" -------- """
################
""" Armature """
col = layout.column(align=True)
col.label(text="Armature")
col.operator("armature.extrude_move", text="Extrude")
col.operator("armature.duplicate_move",text="Duplicate")
col.operator("armature.merge")
col = layout.column(align=True)
row = col.row(align=True)
row.operator("armature.subdivide",text="Subdivide")
row.operator("armature.subdivide",text="Subdivide 2").number_cuts=2
row = col.row(align=True)
row.operator("armature.select_hierarchy").direction="PARENT"
row.operator("armature.select_hierarchy").direction="CHILD"
row = col.row(align=True)
row.operator("armature.fill",text="Fill Between")
row.operator("armature.switch_direction")
row = col.row(align=True)
row.operator("armature.parent_set")
row.operator("armature.parent_clear")
row = col.row(align=True)
row.operator("armature.calculate_roll")
row.operator("armature.switch_direction")
""" Motion """
col = layout.column(align=True)
col.label(text="Motion Paths")
row = col.row(align=True)
row.operator("object.paths_calculate", text="",icon="ANIM_DATA")
row.operator("object.paths_clear", text="",icon="PANEL_CLOSE")
""" Grease """
col = layout.column(align=True)
col.label(text="Grease")
row = col.row(align=True)
row.operator("gpencil.draw", text="",icon="GREASEPENCIL").mode = 'DRAW'
row.operator("gpencil.draw", text="",icon="OUTLINER_OB_CURVE").mode = 'DRAW_STRAIGHT'
row.operator("gpencil.draw", text="",icon="OUTLINER_OB_MESH").mode = 'DRAW_POLY'
row.operator("gpencil.draw", text="",icon="PANEL_CLOSE").mode = 'ERASER'
row.prop(context.tool_settings, "use_grease_pencil_sessions",text="Sketch")
""" ------------------------------------------------ """
""" ------------------------------------------------ """
""" Pose Mode"""
if bpy.context.mode=="POSE":
col = layout.column(align=True)
""" Objects """
""" View """
col = layout.column(align=True)
row = col.row(align=True)
row.operator("view3d.view_persportho",text="View")
row.operator("mesh.primitive_plane_add",icon='MESH_PLANE',text="")
row.operator("mesh.primitive_cube_add",icon='MESH_CUBE',text="")
row.operator("mesh.primitive_circle_add",icon='MESH_CIRCLE',text="")
row.operator("mesh.primitive_uv_sphere_add",icon='MESH_UVSPHERE',text="")
row.operator("mesh.primitive_ico_sphere_add",icon='MESH_ICOSPHERE',text="")
""" Origin """
row = col.row(align=True)
row.operator("object.origin_set", text="Origin")
row.operator("mesh.primitive_grid_add",icon='MESH_GRID',text="")
row.operator("mesh.primitive_monkey_add",icon='MESH_MONKEY',text="")
row.operator("mesh.primitive_cylinder_add",icon='MESH_CYLINDER',text="")
row.operator("mesh.primitive_torus_add",icon='MESH_TORUS',text="")
row.operator("mesh.primitive_cone_add",icon='MESH_CONE',text="")
""" Add Curve """
row = col.row(align=True)
row.operator("transform.translate",text="Locate")
row.operator("curve.primitive_bezier_curve_add",icon='CURVE_BEZCURVE',text="")
row.operator("curve.primitive_bezier_circle_add",icon='CURVE_BEZCIRCLE',text="")
row.operator("curve.primitive_nurbs_curve_add",icon='CURVE_NCURVE',text="")
row.operator("curve.primitive_nurbs_circle_add",icon='CURVE_NCIRCLE',text="")
row.operator("curve.primitive_nurbs_path_add",icon='CURVE_PATH',text="")
""" Add Surface """
row = col.row(align=True)
row.operator("transform.rotate")
row.operator("surface.primitive_nurbs_surface_circle_add",icon='SURFACE_NCIRCLE',text="")
row.operator("surface.primitive_nurbs_surface_surface_add",icon='SURFACE_NSURFACE',text="")
row.operator("surface.primitive_nurbs_surface_cylinder_add",icon='SURFACE_NCYLINDER',text="")
row.operator("surface.primitive_nurbs_surface_sphere_add",icon='SURFACE_NSPHERE',text="")
row.operator("surface.primitive_nurbs_surface_torus_add",icon='SURFACE_NTORUS',text="")
""" Add """
row = col.row(align=True)
row.operator("transform.resize", text="Scale")
row.operator("object.armature_add",text="",icon="BONE_DATA")
row.operator("object.add",text="",icon="OUTLINER_OB_LATTICE").type="LATTICE"
row.operator("object.speaker_add",icon='OUTLINER_OB_SPEAKER',text="")
row.operator("object.camera_add",icon='OUTLINER_OB_CAMERA',text="")
row.operator("object.lamp_add",icon='OUTLINER_OB_LAMP',text="")
""" -------- """
################
col = layout.column(align=True)
col.label(text="Pose")
#ob = context.object
#bone = context.bone
#pchan = ob.pose.bones[bone.name]
#col.prop(pchan, "rotation_mode")
#col = layout.column(align=True)
row = col.row(align=True)
row.operator("pose.copy")
row.operator("pose.paste")
row = col.row(align=True)
row.operator("pose.loc_clear",text="Clear Loc")
row.operator("pose.rot_clear",text="Clear Rot")
row = col.row(align=True)
row.operator("pose.scale_clear",text="Clear Scale")
row.operator("pose.transforms_clear",text="Clear All")
""" Keyframes """
if active_object and active_object.type in {'MESH', 'CURVE', 'SURFACE', 'ARMATURE'}:
col = layout.column(align=True)
col.label(text="Keyframes (I) (Alt+I)")
row = col.row(align=True)
row.operator("anim.keyframe_insert_menu", icon='ZOOMIN', text="")
row.operator("anim.keyframe_delete_v3d", icon='ZOOMOUT', text="")
row.prop_search(scene.keying_sets_all, "active", scene, "keying_sets_all", text="")
row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
""" Motion """
col = layout.column(align=True)
col.label(text="Motion Paths")
row = col.row(align=True)
row.operator("object.paths_calculate", text="",icon="ANIM_DATA")
row.operator("object.paths_clear", text="",icon="PANEL_CLOSE")
""" Grease """
col = layout.column(align=True)
col.label(text="Grease")
row = col.row(align=True)
row.operator("gpencil.draw", text="",icon="GREASEPENCIL").mode = 'DRAW'
row.operator("gpencil.draw", text="",icon="OUTLINER_OB_CURVE").mode = 'DRAW_STRAIGHT'
row.operator("gpencil.draw", text="",icon="OUTLINER_OB_MESH").mode = 'DRAW_POLY'
row.operator("gpencil.draw", text="",icon="PANEL_CLOSE").mode = 'ERASER'
row.prop(context.tool_settings, "use_grease_pencil_sessions",text="Sketch")
""" ------------------------------------------------ """
""" ------------------------------------------------ """
def register():
bpy.utils.register_class(VIEW3D_PT_View3D_Tools)
def unregister():
bpy.utils.unregister_class(VIEW3D_PT_View3D_Tools)
if __name__ == "__main__":
register()

File Metadata

Mime Type
text/x-python
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6f/ae/8f606c3fb2790328566db8e7bee3

Event Timeline