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

    MoText dosn't updates after changing MoGraph Weightmap

    Cinema 4D SDK
    python r20
    2
    3
    570
    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.
    • mikeudinM
      mikeudin
      last edited by ferdinand

      Hello all!
      I have this python code running in a Python Tag:

      import c4d
      from c4d.modules import mograph as mo
      from c4d.utils import RangeMap
      
      def main():
      
          obj = op.GetObject()
          cl_count = mo.GeGetMoData(obj).GetCount()
      
          spline = obj[c4d.ID_USERDATA,2]
      
          ms_tag = obj.GetTag(c4d.Tmgweight)
      
          if not ms_tag:
              print 'No weight tag'
              return
      
          wlist = []
      
          for val in xrange(cl_count):
              res = RangeMap(value=val, mininput=0, maxinput=cl_count-1, minoutput=0.0, maxoutput=1.0, clampval=False,curve=spline)
              wlist.append(res)
      
          mo.GeSetMoDataWeights(ms_tag,wlist)
      

      it works if applied to Matrix Object, Cloner, but problem with MoText it updates after object reenabling.
      In Cinema 4D R18 it works fine.
      alt text
      0_1551888567454_mikeudin_mograph_tag_weight.c4d

      Checkout my python tutorials, plugins, scripts, xpresso presets and more
      https://mikeudin.net

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

        Hi @mikeudin, first of all, I would like to remind you about the Q&A New Functionality, I've setup your post as a question but please try to do it yourself for the next topics.

        With that's said, some optimizations have been done since R18 and now a MoText retrieves data from its Tmgweight only if this one is getting dirty while before it was retrieved for each execution.
        Unfortunately, the Python method GeSetMoDataWeights have not been adapted, so I've filled a BugReport, for now, please consider to call

            mo.GeSetMoDataWeights(ms_tag, wlist)
            ms_tag.SetDirty(c4d.DIRTYFLAGS_DATA)
        
            # Since you are in a tag, next one are not necessary since tag is part of the scene graph execution
            # and are executed before the current object evaluated.
            # Meaning that obj GetVirtualObject will be called in in any case after reading the tag
            # and since the dirty count of the tag has changed, the Motext will retrieve them and not the one cached.
            obj.SetDirty(c4d.DIRTYFLAGS_DATA)
            obj.Message(c4d.MSG_UPDATE)
        

        Btw, thanks a lot for the scene, that help us to quickly reproduce the issue !

        If you have any questions, please let me know.
        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

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

          This issue is now fixed in R21. So you don't need to manually SetDirty / Send the message.

          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

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