blender瞎玩2_自制(?)Maya热盒的笨方法(二)
通过修改官方插件pie menu实现maya热盒
(7)
再贴个Maya的shift+右键热盒改法,这时我们发现blen的pie menu没有类似的功能,那就只能改改改了,我选用了pie_save_open_menu.py这个文件(可怜)
文件里原有的组删不删都行,如果你要加入新组,在原有的组下面接一个class就行了,不过首先你写的组不能出bug,然后还要把你的组名加入以下组
classes = (
PIE_MT_SaveOpen,
PIE_OT_FileIncrementalSave,
PIE_MT_fileio,
PIE_MT_recover,
PIE_MT_link,
PIE_OT_cube,
PIE_OT_sphere,
PIE_OT_plane,
PIE_OT_cylinder,
PIE_OT_gpencil,
PIE_OT_text,
PIE_OT_bone,
PIE_OT_cone,
)
后面8个都是我加的组名。
既然俺不会编程,那所谓的新组当然也是改的,比如以下,maya的热盒添加cube功能,
class PIE_OT_cube(Operator):
bl_idname = "class.cube"
bl_label = "Add Cube"
bl_description = "Add Cube"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
ob = context.object
if not ob or not ob.select_get():
bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, location=(0, 0, 0))
else:
bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, location=(0, 0, 0))
return {'FINISHED'}
这段代码一看就很有问题,不过,whatever,反正实用起来没啥问题
(8)
以下是我记录的有用的功能信息
功能
指令
图标名
添加盒子
bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, location=(0, 0, 0))
MESH_CUBE
添加经纬球
bpy.ops.mesh.primitive_uv_sphere_add(radius=1, enter_editmode=False, location=(0, 0, 0))
MESH_UVSPHERE
添加平面
bpy.ops.mesh.primitive_plane_add(size=2, enter_editmode=False, location=(0, 0, 0))
MESH_PLANE
添加圆柱
bpy.ops.mesh.primitive_cylinder_add(radius=1, depth=2, enter_editmode=False, location=(0, 0, 0))
MESH_CYLINDER
添加圆锥
bpy.ops.mesh.primitive_cone_add(radius1=1, radius2=0, depth=2, enter_editmode=False, location=(0, 0, 0))
MESH_CONE
添加空蜡笔
bpy.ops.object.gpencil_add(location=(0, 0, 0), type='EMPTY')
OUTLINER_OB_GREASEPENCIL
添加文本
bpy.ops.object.text_add(enter_editmode=False, location=(0, 0, 0))
OUTLINER_OB_FONT
添加单段骨骼
bpy.ops.object.armature_add(enter_editmode=False, location=(0, 0, 0))
BONE_DATA
这里介绍一个官方插件,专门用来看功能的图标的
Development:Icon Viewer


(9)
最后得到:
class PIE_MT_SaveOpen(Menu):
bl_idname = "PIE_MT_saveopen"
bl_label = "Pie Save/Open"
def draw(self, context):
layout = self.layout
ob = context.object
# No Object Selected #
if not ob or not ob.select_get():
pie = layout.menu_pie()
# 4 - LEFT
pie.operator("class.sphere", text="Add Sphere", icon='MESH_UVSPHERE')
# 6 - RIGHT
pie.operator("class.bone", text="Add Bone", icon='BONE_DATA')
# 2 - BOTTOM
pie.operator("class.cube", text="Add Cube", icon='MESH_CUBE')
# 8 - TOP
pie.operator("class.gpencil", text="Add Gpencil", icon='OUTLINER_OB_GREASEPENCIL')
# 7 - TOP - LEFT
pie.operator("class.plane", text="Add Plane", icon='MESH_PLANE')
# 9 - TOP - RIGHT
pie.operator("class.text", text="Add Text", icon='OUTLINER_OB_FONT')
# 1 - BOTTOM - LEFT
pie.operator("class.cylinder", text="Add Cylinder", icon='MESH_CYLINDER')
# 3 - BOTTOM - RIGHT
pie.operator("class.cone", text="Add Cone", icon='MESH_CONE')
然后ctrl+s保存,完事。

(10)
附上两个文件,覆盖在/2.81/scripts/addons/space_view3d_pie_menus/里就行,大概,我并不知道有啥后果
【覆盖之前记得备份】,如果出错就覆盖回来















































































