MoData.GetFalloffs() returns reversed list?



  • On 18/04/2017 at 11:08, xxxxxxxx wrote:

    Hello! It seems that in a Python Effector set to Full Control, I need to reverse the falloff array index pointer in order to access the matching clone from any other modata array? It seems that GetFalloffs returns the array in reverse?

    Also, I do not understand the purpose of MoData.SetArray(id, arr, apply_strength ). It seems to apply the falloff more accurately with apply_strength set to False.

    The default example loaded in the Full Control Python Effector does not properly apply the falloff set in the Effector's Falloff tab. Here is the example of how I hacked that default script to work properly with the Falloff set in the Effector's Falloff tab.

    import c4d
    from c4d.modules import mograph as mo
    #Welcome to the world of Python
      
    def main() :
        md = mo.GeGetMoData(op)
        if md is None: return False
        
        cnt = md.GetCount()
        marr = md.GetArray(c4d.MODATA_MATRIX)
        fall = md.GetFalloffs()
        for i in reversed(xrange(0, cnt)) :
            marr[i].off = marr[i].off+fall[cnt-i-1]*100.0
        
        md.SetArray(c4d.MODATA_MATRIX, marr, False)
        return True
    

    The only parts I modified were the "cnt-i-1" which reverses the index pointer to the falloff array, and setting the apply_strength parameter of SetArray( to False.

    Maybe someone can explain to me why it is this way? Seems like a bug, but I am not sure yet so I didn't want to post it in the Bug Report forum quite yet!

    Thank you!

    Jenny



  • On 18/04/2017 at 11:17, xxxxxxxx wrote:

    Oh right, the C4D version number might be important: R17.055 (Build RB174353)

    Thank you again



  • On 18/04/2017 at 13:04, xxxxxxxx wrote:

    If you get the last array element and work backwards. You don't need to worry about accidentally asking for an element that doesn't exist (out of bounds error).

    I don't know the "official" reason.
    But since the marr is mostly used to expand and contract it's element size. It seems safer to work backwards from the last element like this. Rather than getting the array size and traversing forwards like you're probably more accustomed to doing it.

    -ScottA



  • On 19/04/2017 at 02:20, xxxxxxxx wrote:

    Hi Jenny,

    I confirm MoData.GetFalloffs() returns the falloffs in the reverse order. And, in the default code for Python Effector in Full Control mode, falloffs from MoData.GetFalloffs() are processed in reverse order. So there is nothing wrong here.

    But you're right, the default code does not access the right index inside the loop. Because MODATA_MATRIX expects its array to be in progressive order.
    This issue will be reported and fixed in a future release.

    About MoData.SetArray() apply_strength parameter. If it is set to True , then the function simply applies the Effector Strength value shown in the UI.



  • On 24/04/2017 at 13:46, xxxxxxxx wrote:

    Thanks so much for the replies fellas!

    Glad to hear that I wasn't just going mad and that it is a problem... and that it will be getting fixed! Cool!

    Thanks again :)

    Jenny


Log in to reply