Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
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()
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.
GetMg and SetMg
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
Excuse me, I thought I translated it was my mistake, and in the same way, thank you for your help.