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

    GetContour() refresh or uncache? How?

    PYTHON Development
    0
    21
    16.5k
    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.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 22/10/2011 at 16:27, xxxxxxxx wrote:

      Nope, its AM needs a "real" input to refresh the GetContour().

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 22/10/2011 at 16:45, xxxxxxxx wrote:

        What about triggering a hidden UserData field in your code to update it instead?

        Here's the GetContour() method of the Py-DoubleCircle.pyp SDK example. But with some code added to it that will hide the first UD entry. So the user never sees you using it:

            def GetContour(self, op, doc, lod, bt) :  
              bc = op.GetDataInstance()  
              bp = self.GenerateCircle(bc.GetReal(c4d.PYCIRCLEOBJECT_RAD))  
              if not bp: return None  
              bb = bp.GetDataInstance()  
                
              bb.SetLong(c4d.SPLINEOBJECT_INTERPOLATION, bc.GetLong(c4d.SPLINEOBJECT_INTERPOLATION))  
              bb.SetLong(c4d.SPLINEOBJECT_SUB, bc.GetLong(c4d.SPLINEOBJECT_SUB))  
              bb.SetReal(c4d.SPLINEOBJECT_ANGLE, bc.GetReal(c4d.SPLINEOBJECT_ANGLE))  
              bb.SetReal(c4d.SPLINEOBJECT_MAXIMUMLENGTH, bc.GetReal(c4d.SPLINEOBJECT_MAXIMUMLENGTH))  
                
              DoubleCircleData.OrientObject(bp, bc.GetLong(c4d.PRIM_PLANE), bc.GetBool(c4d.PRIM_REVERSE))  
                
              UD = op.GetUserDataContainer()         #Get the the container for all UD entries  
              for descId, container in UD:           #Loop through all the id's in the container  
                if descId[1].id == 1:                #Gets the first UD entry             
                   container[c4d.DESC_HIDE] = True   #Set it to hidden in memory only  
                   op.SetUserDataContainer(descId, container) #Execute that hidden setting from memory  
                   c4d.EventAdd()  
                
              return bp
        

        -ScottA

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 22/10/2011 at 17:29, xxxxxxxx wrote:

          Thanks Scott you're most kind, but as mentioned
          any external forced triggering bogs the setup down severly.
          Using GetVirtualObjects() there is no lag at several thousands
          of segments of the resulting spline.

          Cheers
          Lennart

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 29/01/2012 at 15:42, xxxxxxxx wrote:

            Any updates on this one?

            Why is there no answer from Maxon?

            Same here:
            https://developers.maxon.net/forum/topic/6058/6220_basic-pygenerator-plugin-please&KW=create+spline&PN=1

            Cheers,
            André

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 03/02/2012 at 08:00, xxxxxxxx wrote:

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 03/02/2012 at 08:00, xxxxxxxx wrote:

                Any news? Still waiting ...

                Cheers,
                maxx

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 03/02/2012 at 08:44, xxxxxxxx wrote:

                  Hi maxx,

                  this seems to work well. However, it is not really satisfying using that hack..

                  http://www.file-upload.net/download-4083773/GetContour.zip.html

                  Cheers, Niklas!

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 04/02/2012 at 09:09, xxxxxxxx wrote:

                    Originally posted by xxxxxxxx

                    Hi maxx,

                    this seems to work well. However, it is not really satisfying using that hack..

                    http://www.file-upload.net/download-4083773/GetContour.zip.html

                    Cheers, Niklas!

                    Hy nux, thanx for Code. But as you say, its not really satisfying. As tcastudios wrote, doing this will have severe performance drawbacks ...

                    Cheers,
                    André

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 04/04/2012 at 05:41, xxxxxxxx wrote:

                      So we have reason to believe that there is no Cache to release for GetContour()
                      in a similar manner as one can do with GetVirtualObjects() by not returning
                      a HierarchyHelp ?

                      Cheers
                      Lennart

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 04/04/2012 at 07:23, xxxxxxxx wrote:

                        Hi,

                        I contacted the developers on this issue.

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 04/04/2012 at 08:47, xxxxxxxx wrote:

                          Great, thanks Yannick.

                          Cheers
                          Lennart

                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 10/04/2012 at 07:27, xxxxxxxx wrote:

                            Here's the information I got from the developers.

                            Splines created though GetContour() are cached. To make this frame dependent CheckDirty() can be overloaded to set the object dirty if a certain condition has changed:

                            class TestSplineData(plugins.ObjectData) :
                                
                                def __init__(self) :
                                    doc = documents.GetActiveDocument()
                                    self.lastFrame = doc.GetTime().GetFrame(doc.GetFps())
                                
                                def CheckDirty(self, op, doc) :
                                    print "CheckDirty()"
                                    
                                    frame = doc.GetTime().GetFrame(doc.GetFps())
                                    if frame != self.lastFrame:
                                        self.lastFrame = frame
                                        op.SetDirty(c4d.DIRTYFLAGS_DATA)
                                
                                def GetContour(self, op, doc, lod, bt) :
                                    print "GetContour()"
                                    
                                    return c4d.BaseObject(c4d.Ospline)
                            

                            This should only be done if absolutely necessary though, otherwise the spline (and all depending objects) will be rebuilt for every single view-redraw.

                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 10/04/2012 at 08:13, xxxxxxxx wrote:

                              Thank you very much,Yannick! That is a big step in the right direction.
                              I will try to get all In/Excl objects within the CheckDirty() because that is
                              the "core" issue I have. The generator should update on the list's object's
                              dirty status.
                              I'll report how a get (or don't get! it working.

                              Cheers
                              Lennart

                              1 Reply Last reply Reply Quote 0
                              • H
                                Helper
                                last edited by

                                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                On 10/04/2012 at 10:46, xxxxxxxx wrote:

                                YES YES! I'm so happy that this is solved, thanks a lot.
                                I've posted the important parts of one plugin I'm working with.
                                It needs to get dirty info from objects in a In/Excl List so I
                                simply could loop them and check the sum against the stored dirty sum.
                                Then to bypass the potential problems using GetActiveDocument() (for not active document)
                                I simply treat the current frame as a dirty (Long) value and include it in
                                the dirty sum!

                                Could not be happier!

                                Cheers
                                Lennart

                                """   
                                splineGLIDE   
                                Copyright: tcastudios 2012   
                                Written for CINEMA 4D R13.+   
                                  
                                Modified Date: 2012xxxx   
                                """   
                                  
                                import c4d   
                                import os   
                                import webbrowser as w   
                                from c4d import plugins, utils as u, bitmaps, Vector as v, documents   
                                from c4d.utils import SplineHelp, SplineLengthData   
                                  
                                PLUGIN_ID = 1028358 # PLUGIN ID registered by tcastudios. IF YOU MAKE ANY EDITS YOU MUST GET A NEW PLUGIN ID FROM plugincafe.com!!   
                                DIRTYSUM = 1027373 # Unique ID from plugincafe.com registered by tcastudios.com (PCLUSTER_MEMO)   
                                  
                                class sGLIDE(plugins.ObjectData) :   
                                     """splineGLIDE Generator"""   
                                        
                                     def Init(self, sglide) :   
                                          data = sglide.GetDataInstance()   
                                          data.SetReal(c4d.SG_MIX,1.0) # Mix Float   
                                          data.Set etc……   
                                          return True   
                                  
                                     def CheckDirty(self,op,doc) :   
                                          obc        = op.GetDataInstance()   
                                          dirtysumbc = obc.GetContainer(DIRTYSUM)   
                                          dlist      = obc.GetData(c4d.SG_SOURCES) #InExclude List objects to get dirty from   
                                          lcount     = dlist.GetObjectCount()   
                                             
                                          checksum = doc.GetTime().GetFrame(doc.GetFps()) # Use frame as a dirty integer (Long)   
                                          for d in xrange(lcount) :   
                                               checksum += dlist.ObjectFromIndex(None ,d ).GetDirty(c4d.DIRTY_DATA|c4d.DIRTY_MATRIX |c4d.DIRTY_CHILDREN|c4d.DIRTY_CACHE|c4d.DIRTY_SELECT)   
                                  
                                          if (checksum != dirtysumbc.GetLLong(0)) :   
                                               dirtysumbc.SetLLong(0,checksum)   
                                               obc.SetData(DIRTYSUM,dirtysumbc)        # Store new checksum into Container   
                                  
                                     def Construct(self,sglide) :   
                                          sbc        = sglide.GetDataInstance()   
                                          myfader    = sbc.GetReal(c4d.SG_MIX)   
                                          myetc      = sbc.Get etc etc   
                                          myspline   =   
                                          myspline   = c4d.BaseObject(c4d.Ospline)   
                                          # code that do things with spline from In/Excl List objects   
                                          return     myspline   
                                  
                                     def GetContour(self, sglide, doc, lod, bt) :   
                                          return self.Construct(sglide)   
                                  
                                if __name__ == "__main__":   
                                    path, file = os.path.split(__file__)   
                                    bmp = bitmaps.BaseBitmap()   
                                    bmp.InitWith(os.path.join(path, "res", "splineGLIDE.tif"))   
                                    splineGLIDELoaded = plugins.RegisterObjectPlugin(id=PLUGIN_ID,   
                                                    str="splineGLIDE",   
                                                                g=sGLIDE,   
                                                                description="splineGLIDE",   
                                                                icon=bmp,   
                                                                info=c4d.OBJECT_GENERATOR | c4d.OBJECT_ISSPLINE )   
                                                                   
                                    if splineGLIDELoaded:   
                                        print 'splineGLIDE v1 Loaded'   
                                

                                edit: Don't need to set checksum again for the op.

                                1 Reply Last reply Reply Quote 0
                                • H
                                  Helper
                                  last edited by

                                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                  On 06/09/2012 at 09:37, xxxxxxxx wrote:

                                  I've been struggling with this in C++ just a few seconds ago. I'm so happy I remembered this thread. 🙂
                                  I couldn't find this information in the C++ docs as well. Especially because CheckDirty() is listed under methods for Modifier objects, it didn't appear to me that I need to override this method.

                                  -NIklas

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