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

    problema de regreso de código de gestor de scripts

    General Talk
    2
    3
    657
    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.
    • JH23J
      JH23
      last edited by JH23

      I made a small script to do or fake the psr command but they are restoring the rotation
      The problem is that when I try to return, it does not react

      import c4d
      from c4d import documents, plugins
      def main():
          def object():
              return doc.GetActiveObject()
          object()[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Y] = 0
          object()[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_X] = 0
          object()[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Z] = 0
          c4d.EventAdd()
      if __name__=='__main__':
          main()
      
      
      
      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by Manuel

        hi,
        please use English for your communication

        if i understood correctly your question, you want to implement an undo stack.
        This script will help you to understand how it can be done. Please have a look at the documentation for more information.
        We also have an undo manual for c++ that could help you to understand how it's working.

        The following script will reset the position for each selected object. It will only reset the local position of the object. You could try to improve it using the ctrl key to reset the global position. (you would need to use GetMg and SetMg instead.

        Please read our documentation about matrices. to understand how they work and how you can use them.

        import c4d
        from c4d import documents, plugins
        def main():
            # Retrieve all the selected object
            objects = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_NONE)
            # Start a new undo stack
            doc.StartUndo()
            
            # For each selected object
            for obj in objects:
                # Retrieve the local Matrix
                ml = obj.GetMl()
                # Define a new offset vector with the one by default (0, 0, 0)
                ml.off = c4d.Vector()
                # Add a stem in the undo stack for this object.(sot it previous state will be stored)
                doc.AddUndo(c4d.UNDOTYPE_CHANGE, obj)
                # Change the obect's position.'
                obj.SetMl(ml)
            # Close the stack.    
            doc.EndUndo()
        
            c4d.EventAdd()
        if __name__=='__main__':
            main()
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • JH23J
          JH23
          last edited by

          Excuse me, I thought I translated it was my mistake, and in the same way, thank you for your help.

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