Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Skin Weights File Parser?

    Cinema 4D SDK
    python 2023
    2
    3
    307
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bentraje
      last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • B
        bentraje
        last edited by

        ===

        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.

        1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by

          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

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • First post
            Last post