Preferred, safe method for getting deformed points



  • On 05/04/2016 at 13:47, xxxxxxxx wrote:

    Hello all,

    I keep getting crashes on particular objects when I run the GetCache() method outlined in the sdk (pasted below for convenient reference).  The worst offender seems to be this polygon object with a few deformers, one of them being the mesh deformer--though I don't know if it has anything to do with the object or if I'm actually calling it incorrectly (just from the script manager, at the moment).

    Anyway, I started going the send modeling command route, ie:

    surface2list = [geo]
      
    settings = c4d.BaseContainer()    
    settings.SetBool(c4d.MDATA_CURRENTSTATETOOBJECT_INHERITANCE, True)
            
    polysurface = c4d.utils.SendModelingCommand(c4d.MCOMMAND_CURRENTSTATETOOBJECT, surface2list, bc=settings, doc=doc)
    

    It works, so I guess my question is: is this (the send modeling command) bad practice for any particular reason/should I find out how to properly utilize the cache method, instead?  I'm sure I've seen this used before in a recent search, but in my case it will go through every frame and run the conversion every time (sometimes on more than one object) to get the point info it needs.  Does that all make sense?

    Here's the cache method from the sdk I was talking about, though I'm sure most of you know what I meant.

    def DoRecursion(op) :
      tp = op.GetDeformCache()
      if tp is not None:
        DoRecursion(tp)
      else:
        tp = op.GetCache()
        if tp is not None:
          DoRecursion(tp)
        else:
          if not op.GetBit(c4d.BIT_CONTROLOBJECT) :
            if op.IsInstanceOf(c4d.Opolygon) :
              ...
    
      tp = op.GetDown()
      while tp is not None:
        DoRecursion(tp)
        tp = tp.GetNext()
    

    Thanks for any advice!



  • On 06/04/2016 at 01:47, xxxxxxxx wrote:

    Hello,

    can you share some more information on what you are doing? What Cinema 4D version do you use? In what context do you execute your code, what kind of plugin are you writing?

    I cannot reproduce any crash with the recursion code and the mesh deformer. Can you share more information on that?

    Accessing the cache of objects has the benefit hat this is faster – since you access something that is already there. Using SendModelingCommand() is probably slower but would also work in a situation where there is no cache. But without knowing what exactly you are doing it is hard to make any statement.

    Best wishes,
    Sebastian



  • On 06/04/2016 at 08:16, xxxxxxxx wrote:

    Hey, thanks Bach.

    I was in the middle of pasting my code, here, when it occurred to me that a likely culprit was the dang InsertObject() in it later on--I added it just to look at the mesh once and make sure DoRecursion() (above) was behaving as expected.  As soon as I appended GetClone() to the mesh and inserted that, instead, no more crashes 😪

    Really should have suspected that before posting--I had tunnel vision!  Sorry for sending you on a goose chase.

    Not that it matters anymore, but I was pretty much just executing this and little else from the Script Manager, and I'm on R16.051.

    Thanks again!


Log in to reply