SOLVED get initial position in python tag

does anyone know how i can get my starting position? and keep locked, without changing it? how does PSR's Maintain Original do?



The tag store the data in its BaseContainer.

    for i in xrange(tag[c4d.ID_CA_CONSTRAINT_TAG_PSR_TARGET_COUNT]):
            print "matrix", tag[c4d.ID_CA_CONSTRAINT_TAG_PSR_TARGET_COUNT + i * 10 + 3]
            print "scale", tag[c4d.ID_CA_CONSTRAINT_TAG_PSR_TARGET_COUNT + i * 10 + 4]

You can do the same. Storing the data inside the BaseContainer of the tag offer the advantage that it will be saved and loaded automatically when you save the document. (you can also have a look at the c++ BaseContainer Manual)


Oh! Thank you! but I think you don't understand

I need to create code similar to a PSR and I need the Maintain Original option, for that I need a "LOOK POSITION", because the python tag is executed in a loop, I need to get a position only if I activate the Maintain Original, and after that do not change the value.


well you should store the value and the fact that you already did stored the value inside the BaseContainer

something like so, where op[c4d.ID_USERDATA,1] is my "lock position" Boolean UserData

import c4d

myPersonnalID = 100000 # This ID should be a unique ID retrieve on

def main():
    # Retrieves the BaseContainer of the tag
    bc = op.GetDataInstance()
    # Retrieves my personnal BaseContainer
    myData = bc.GetContainer(myPersonnalID)
    if myData is None:
        # First Init of the tag
        myData = c4d.BaseContainer()
        myData.SetBool(1000, op[c4d.ID_USERDATA,1]) #Everything should be False but let's initiate the value with the UserData's value
        bc.SetContainer(myPersonnalID, myData)
    if op[c4d.ID_USERDATA,1] and not myData[1000]:
        # the Bool is activated and because it's not in our baseContainer, it's the first time
        # Actives the Bool in our baseContainer
        myData.SetBool(1000, True)
        # Stores the object's Matrix in our BaseContainer
        myData.SetMatrix(1001, op.GetObject().GetMg())
        # Updates the tag's BaseContainer
        bc.SetContainer(myPersonnalID, myData)
    if not op[c4d.ID_USERDATA,1]:
        # the Bool is desactivated in the UI, we update our container and remove the data.
        # Updates the tag's BaseContainer
        bc.SetContainer(myPersonnalID, myData)
    print op[myPersonnalID][1000], op[myPersonnalID][1001]



without further feedback i'll set this thread as solved tomorrow.