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
    • Register
    • Register
    • Login

    get initial position in python tag

    Cinema 4D SDK
    r19 r20 r21 classic api python
    2
    5
    834
    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.
    • pyxelriggerP
      pyxelrigger
      last edited by Manuel

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

      60172915-6740-4cba-a153-e5d64372d03b-image.png

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by Manuel

        Hi,

        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)

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • pyxelriggerP
          pyxelrigger
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            Hi,

            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 plugincafe.maxon.net
            
            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.
                    myData.RemoveData(1001)
                    myData.RemoveData(1000)
                    # Updates the tag's BaseContainer
                    bc.SetContainer(myPersonnalID, myData)
                    
                
                print op[myPersonnalID][1000], op[myPersonnalID][1001]
            

            Cheers
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • ManuelM
              Manuel
              last edited by

              hi,

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

              Cheer,
              Manuel

              MAXON SDK Specialist

              MAXON Registered Developer

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