43 lines
1.3 KiB
Markdown
43 lines
1.3 KiB
Markdown
|
```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)
|
||
|
```
|