BlenderCN论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 779|回复: 0

shape key工具 把指定的形变坐标付给选中的顶点bpy

[复制链接]
发表于 2015-4-26 09:57:23 | 显示全部楼层 |阅读模式
本帖最后由 岸子岸子 于 2015-5-1 20:01 编辑
  1. bl_info = {
  2.     "name": "shapeKeyTool",
  3.     'author':'Jianzwan',
  4.     'version':(1,0),
  5.     "blender":(2,72,0),
  6.     "location":'View3D>Tool shelf',
  7.     "category": "Mesh",
  8. }
  9. #in blender2.72
  10. import bpy
  11. import bmesh

  12. bpy.types.Mesh.shapeName1 = bpy.props.StringProperty(default = 'Basis')
  13. bpy.types.Mesh.shapeName2 = bpy.props.StringProperty(default = 'Key 1')
  14. bpy.types.Mesh.shapeName3 = bpy.props.StringProperty(default = 'Key 2')

  15. class setShapeKeys(bpy.types.Operator):
  16.     bl_idname= "mesh.shpks"
  17.     bl_label= "SET"
  18.     bl_options= {'REGISTER', 'UNDO'}
  19.    
  20.     keybl = bpy.props.StringProperty(default = '')
  21.     #x = bpy.props.CollectionProperty()
  22.    
  23.     def execute(self,context):
  24. #        shpK = 'Basis'
  25.         print('\n')
  26.         obj = bpy.context.active_object

  27.         bm = bmesh.from_edit_mesh(obj.data)
  28.         bv = bm.verts
  29.         sltPbv=[]

  30.         for pbv in bv:
  31.             print(pbv.select,pbv.co,obj.data.vertices[pbv.index].co)
  32.             if pbv.select == True:
  33. #                pbv.co = obj.data.shape_keys.key_blocks[shpK].data[pbv.index].co
  34.                 pbv.co = obj.data.shape_keys.key_blocks[self.keybl].data[pbv.index].co
  35.                 sltPbv.append(pbv.index)
  36.         print(bv.layers.shape)

  37.         bmesh.update_edit_mesh(obj.data)
  38.         print('set:',sltPbv)
  39.         
  40.         return {'FINISHED'}

  41. class shapeKeysTool(bpy.types.Panel):
  42.     bl_category = 'Shape Key'
  43.     bl_idname = "shape.shpktool"
  44.     bl_label = "ShapeKey Tool"
  45.     bl_space_type = 'VIEW_3D'
  46.     bl_region_type = 'TOOLS'

  47.     @classmethod
  48.     def poll(cls, context):
  49.         return (context.object is not None)
  50.         
  51.     def draw(self, context):
  52.         obj = bpy.context.active_object

  53.         layout = self.layout
  54.         
  55.         obj = bpy.context.active_object
  56.         column = layout.column()
  57.         row = column.row()
  58.         row.prop(obj.data,"shapeName1",text= '')
  59.         row.operator("mesh.shpks",text= 'SET 1').keybl = obj.data.shapeName1
  60.         row = column.row()
  61.         row.prop(obj.data,"shapeName2",text= '')
  62.         row.operator("mesh.shpks",text= 'SET 2').keybl = obj.data.shapeName2
  63.         row = column.row()
  64.         row.prop(obj.data,"shapeName3",text= '')
  65.         row.operator("mesh.shpks",text= 'SET 3').keybl = obj.data.shapeName3
  66.         
  67. def register():
  68.     bpy.utils.register_class(setShapeKeys)
  69.     bpy.utils.register_class(shapeKeysTool)
  70.    
  71. def unregister():
  72.     bpy.utils.unregister_class(setShapeKeys)
  73.     bpy.utils.unregister_class(shapeKeysTool)

  74. # by  Jianzwan
  75. #if __name__ == "__main__":
  76. #    register()<p></p>
复制代码

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

Blender最新中文教学视频|Blender头条|小黑屋|手机版|Archiver|Blender中国 ( 蜀ICP备17002929号 )360网站安全检测平台

GMT+8, 2019-12-16 10:58 , Processed in 0.018039 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表