vault backup: 2023-12-07 10:08:20
This commit is contained in:
parent
2cd21e7b77
commit
893bbf332f
43
06-DCC/Blender/Blender删除骨骼权重脚本.md
Normal file
43
06-DCC/Blender/Blender删除骨骼权重脚本.md
Normal file
@ -0,0 +1,43 @@
|
||||
```python
|
||||
import bpy
|
||||
#import os
|
||||
import sys
|
||||
|
||||
argv = sys.argv
|
||||
argv = argv[argv.index("--") + 1:] # get all args after "--"
|
||||
# print(argv) # --> ['example', 'args', '123']
|
||||
SourceFBXPath = argv[0]
|
||||
ExportFBXPath = argv[1]
|
||||
RemoveWeightBoneNames = argv[2]
|
||||
RemoveWeightBoneNameList = RemoveWeightBoneNames.split(',')
|
||||
#RemoveWeightBoneNameList = ['calf_twist_01_l','calf_twist_01_r','calf_twist_02_l','calf_twist_02_r','lowerarm_twist_01_l','lowerarm_twist_01_r']
|
||||
|
||||
bpy.ops.scene.new(type='EMPTY')
|
||||
bpy.ops.object.select_all(action='SELECT')
|
||||
bpy.ops.object.delete()
|
||||
|
||||
bpy.ops.import_scene.fbx(filepath=SourceFBXPath)
|
||||
|
||||
for obj in bpy.data.objects:
|
||||
if obj.type == 'MESH':
|
||||
for BoneName in RemoveWeightBoneNameList:
|
||||
vg = obj.vertex_groups.get(BoneName)
|
||||
if vg is not None:
|
||||
obj.vertex_groups.remove(vg)
|
||||
|
||||
bpy.ops.export_scene.fbx(filepath=ExportFBXPath,add_leaf_bones=False)
|
||||
|
||||
# ob = bpy.context.object
|
||||
# if ob.type == 'ARMATURE':
|
||||
# armature = ob.data
|
||||
|
||||
# bpy.ops.object.mode_set(mode='EDIT')
|
||||
|
||||
# for bone in armature.bones:
|
||||
# if fnmatch.fnmatchcase(bone.name, "something"):
|
||||
# armature.delete(bone)
|
||||
|
||||
# for bone in armature.edit_bones:
|
||||
# if fnmatch.fnmatchcase(bone.name, "something"):
|
||||
# armature.edit_bones.remove(bone)
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user