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
    • Register
    • Login

    Easier Way to Modify Pose Morph Strength Based on Name?

    Cinema 4D SDK
    2023 python
    2
    3
    438
    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,

      I can modify the pose morph strength based on name through the following code:

      import c4d
      
      def main():
          morph_name = "smile_wide_L"
          morph_value = 0.8
          for i in range( morph_tag.GetMorphCount()):
              
              descID = tag.GetMorphID(i)
              if tag.GetMorph(i).GetName()==morph_name:
                       tag[descID] = morph_value 
          c4d.EventAdd()        
      

      As you can see, it has to loop through several times to get to the actual morph target to be modified.
      Other DCC API just simply do a variation of this:
      morph_object.morph_name = morph_value

      Is there a better way of doing this?

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @bentraje
        last edited by

        Hi @bentraje,

        Pose morph name is not a unique identifier, meaning that you can theoretically have multiple pose morphs with the same name (even though it doesn't sound practical). Hence you cannot access pose morph in the tag by its name because such indexing is ambiguous.

        If you're sure there're no pose morphs with the same name, then you can create a dictionary that maps pose morph names to its DescIDs and use that instead.

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

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

          @i_mazlov
          Ah yes, my pose morph names are standardized so there should be no duplicated/redundant names.
          And yea, thanks for mentioning the dictionary route. Totally overlooked that.
          That could indeed be an easier way to set/get some values.

          Thanks!

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