2 個の投稿 / 0 new
最終投稿
#1 2019-10-25 05:10

Script: "find unused bones"

I made a Python script that identifies "unused" bones in a PMX model. By "unused" bones, I mean bones that could safely be deleted without changing anything about how the model functions. This could be useful for de-cluttering a model or after importing parts from a different model and you realized you brought in too many bones that aren't connected to anything.
Download: http://tstorage.info/785caeo7fzy7

A bone is USED if any of the following are true:
* other used bones use it as parent, AKA it has children
* other used bones use it as link point
* other used bones use it for 'append' (partial parent)
* it is an IK type bone
* rigid bodies use it as an anchor
* any vertex has nonzero weight with that bone
A bone is UNUSED if none of these conditions are met. If it's not supporting other bones, and not controlling any vertices, and not holding any rigid bodies, then it isn't doing anything and it can be safely deleted without changing a single thing.

However, this does not mean they all SHOULD be removed. The 'glasses' bone that I see on many models, for example, would be considered 'unused' by this script because it is not used in PMXE. But it is a useful attachment point for glasses (accessories) in MMD, so it should probably not be deleted. Think carefully before you delete things, and test thoroughly afterward!

Usage instructions:
* You need to have Python3 installed or else it wont work, duh.
* First, close the model view and transform view windows
* In main window vertex tab, select all vertices (ctrl+A)
* Right click in the list and select "Save as CSV (S)" (note: for complex models, this may take 20-30 seconds)
* Name it "v.csv"
* Repeat for bones "b.csv" and rigid bodies "rb.csv" (note: bones and rigid bodies are significantly faster to save than vertices)
* Put this script in the same directory as these 3 files and double-click to run
* It prints a list of the indexes of the bones that are unused!

Ideally this would be an actual plugin for PMXE instead of a standalone script, because then we could skip the whole "export stuff to CSV" phase, but I dont know how to make such a plugin. If somebody does write a plugin that executes this same logic, please let me know!

2019-10-25 05:20

Nice, thank you for your contribution