Hi,
Just wondering if Skin Weights File can be parsed with existing third party parsers like the python default library configparser
or do we have to make our own?
The configparser
accepts format such as
[CC_Base_Hip]
Mask=false
Type=Body
X=0
Y=116.378128
Z=-1.930478
Which is really close with the skin weights file parser with the exception that the skin weights uses <>
as a section identifier instead of []
[Demo::Weight]
<DEF-spine>
(0) = 0.049
(65) = 0.006
(66) = 0.007
(78) = 0.019
(79) = 0.023
That's why it kinda works but I'm unable to extract the specific sections.
Here's my working code so far:
import configparser
from collections import OrderedDict
class multidict(OrderedDict):
_unique = 0 # class variable
def __setitem__(self, key, val):
if isinstance(val, dict):
self._unique += 1
key += str(self._unique)
OrderedDict.__setitem__(self, key, val)
config = configparser.ConfigParser(defaults=None, dict_type=multidict, strict=False, allow_no_value=True)
config.read("demo_weights.txt")
sections = config.sections() # returns [Demo::Weight] instead of <DEF-spine>
Thanks for looking at my code. No expectation to answer within the week. Have a great holidays ahead!