Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Call "Set Deformed Mesh" on Weight Tag

    Cinema 4D SDK
    2024 python windows
    2
    2
    473
    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.
    • V
      vwgamedev
      last edited by

      Hello, I am currently trying to realize an asset pipeline for our game project that allows us to prepare our characters and clothes for processing in Unity.

      Basically I have found a clean way to do this in Cinema4D that I can do by hand and that leads to success.
      I create a few extra bones that we need and do some renaming. None of this is a big deal. But it is important that we then run the "Set Deformed Mesh". If I do this manually, everything works perfectly, but I just can't find a way to call this function directly in Python. I have found a way to set the button to "Set Deformed Mesh" but this does not "press" it.:

      def apply_deformed_mesh(meshes):
          """
          Apply 'Set Deformed Mesh' on all meshes with weight tags.
          """
          for obj in meshes:
              weight_tag = obj.GetTag(c4d.Tweights)
              if weight_tag:
                  bc = weight_tag.GetDataInstance()
                  
                  # Set the button to 'Set Deformed Mesh'
                  bc.SetInt32(c4d.ID_CA_WEIGHT_TAG_SET_BUTTON, c4d.ID_CA_WEIGHT_TAG_SET_DEFORMED_MESH)
      
                  weight_tag.Message(c4d.MSG_UPDATE)
      
          # Update the scene
          c4d.EventAdd()
      

      Is there a way to execute this command somehow to automate the whole thing?

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi you need to use call button

        def apply_deformed_mesh(meshes):
            """
            Apply 'Set Deformed Mesh' on all meshes with weight tags.
            """
            for obj in meshes:
                weight_tag = obj.GetTag(c4d.Tweights)
                if weight_tag:
                    bc = weight_tag.GetDataInstance()
                    
                    # Set the button to 'Set Deformed Mesh'
                    bc.SetInt32(c4d.ID_CA_WEIGHT_TAG_SET_BUTTON, c4d.ID_CA_WEIGHT_TAG_SET_DEFORMED_MESH)
                    c4d.CallButton(weight_tag, c4d.ID_CA_WEIGHT_TAG_SET_BUTTON)
        
            # Update the scene
            c4d.EventAdd()
        

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

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