Jump to content

Sign in to follow this  

Python Effector - Invert Matrix scale

Recommended Posts

I've created a Python Effector which reads in csv values and scales clones in Y by index.

My only issue is that the script doesn't respect negative values from the csv, and instead scales all clones in the positiveY.

I thinkthis has something to do with matrices, and have read through matrix section the sdk, but can't seem to find a way have negative csv values translate to negativeY scales. Even when I negate the csv values, the effector still scales the clones in the positiveY.

Maybe something simple I'm overlooking, but any help appreciated.




import c4d
from c4d.modules import mograph as mo
import csv
#Welcome to the world of Python

def main():
    csvFile = op[c4d.ID_USERDATA,1]
    csvColName = op[c4d.ID_USERDATA,2]
    count = 0
    myValues = []
    with open(csvFile) as csvfileIn:
        reader = csv.DictReader(csvfileIn)
        for row in reader:
            csvVals = (row[csvColName])
            count += 1
    myRevList = myValues[::-1] #reverses the order of the list
    myFloats = [float(i) for i in myRevList]
    rangeLow = min(myFloats)
    rangeHigh = max(myFloats)
    md = mo.GeGetMoData(op)
    if md is None: return False
    marr = md.GetArray(c4d.MODATA_MATRIX)
    fall = md.GetFalloffs()
    nb = md.GetCount()
    for u in range(0, nb):
        marr[u].v2 = c4d.Vector(0,myFloats[u]*100,0)
    md.SetArray(c4d.MODATA_MATRIX, marr, True)
    return True

if __name__=='__main__':


Share this post

Link to post
  • Topic Author
  • solved it with flipping the X axis rotation value for negative csv values:


    for u in range(0, nb):
            if myFloats[u] < 0:
                marr[u].v1 = c4d.Vector(-1,0,0)
                marr[u].v2 = c4d.Vector(0,myFloats[u]*100,0)
                count += 1
                marr[u].v1 = c4d.Vector(1,0,0)
                marr[u].v2 = c4d.Vector(0,myFloats[u]*100,0)
                count += 1


    Share this post

    Link to post

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Sign in to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    • Create New...