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

    GeGetModata inside Python Generator returns none

    Cinema 4D SDK
    r20 python
    2
    3
    683
    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.
    • P
      pyr
      last edited by

      i use a clone with a null object to generate me some point lists for further processing. unfortunally i'm not able to get the modata from this cloner.

      see setup for details:
      cloneNone.c4d

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

        hello,

        this is because the modata are store in a tag that is not created yet.

        a "workaround" is to create it in a "temporary document" and ExecutePasses() on it.

        So the cloner will create the hidden tag and you will be able to retrieve the MoData

        import c4d
        #Welcome to the world of Python
        
        def CreateClonerAndFun(base, rad):
            """
            Creates the cloner, clone the base.
            Creates the effector
            return the parent and the cloner.
            """
            parent  = c4d.BaseObject(c4d.Onull)
        
            base = base.GetClone()
            base.InsertUnderLast(parent)
        
            cloner  = c4d.BaseObject(1018544)
            cloner.InsertUnder(parent)
        
            p = c4d.BaseObject(c4d.Onull)
            p[c4d.NULLOBJECT_DISPLAY] = 2
            p[c4d.NULLOBJECT_RADIUS] = rad
            p.InsertUnder(cloner)
        
            pushEffector = c4d.BaseObject(440000219)
            pushEffector[c4d.MGPUSHAPARTEFFECTOR_MODE] = 0
            pushEffector[c4d.MGPUSHAPARTEFFECTOR_RADIUS] = rad
            pushEffector.InsertUnderLast(parent)
        
            ie = c4d.InExcludeData()
            ie.InsertObject(pushEffector,15)
            cloner[c4d.ID_MG_MOTIONGENERATOR_MODE] = 0
            cloner[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST] = ie
            cloner[c4d.MG_OBJECT_LINK] = base
            cloner[c4d.MG_POLY_MODE_] = 0
        
        
            return parent, cloner
        
        
        def main():
            # Checks if we got a child
            child = op.GetDown()
            if child is None:
                raise ValueError("no child on this generator")
        
            # using a function to avoid double code
            parent, cloner = CreateClonerAndFun(child, 10)
        
        
            # Creates a new Document
            newDoc = c4d.documents.BaseDocument()
            # Inserts the object in the new document
            newDoc.InsertObject(parent)
        
            # ExecutePasses on the document
            if not newDoc.ExecutePasses(None,True,True,True, c4d.BUILDFLAGS_NONE):
                raise ValueError("erro while updating the document")
        
            # Retrieves the modata from the object
            md = c4d.modules.mograph.GeGetMoData(cloner)
            print md
        
            # Re-create the cloner but this time to return the parent.
            return CreateClonerAndFun(child, 10)[0]
        

        Cheers
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • P
          pyr
          last edited by

          to be honest - i don't know where my fault was. Unhappily i didn't commit the not working version. In my plugin i
          already used a virtual doc for some other calculations. thank you!

          vd.ExecutePasses(c4d.threading.GeGetCurrentThread(), True, True, True, c4d.BUILDFLAGS_NONE)
          md = c4d.modules.mograph.GeGetMoData(matrix)
          for m in md.GetArray(c4d.MODATA_MATRIX): rdPoints.append(m.off)
          

          works like a sharm.

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