SOLVED Skin Weights File Parser?

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!

===

Aparently not possible. Since the subsection for the configparser needs to be dot(.)
like

[Section]
[Section.Subsection]

Just need to preprocess it before parsing I guess.
Basically, replacing <> to []. Done deal.

hi,

this is out of scope of the support and i never used configparser. Maybe maxime or Ferdinand will have some nice tips out of their head without having to investigate.
I am happy you found a solution by pre-processing the file first.

Cheers,
Manuel