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).
Hi,
In this thread, it offers the solution to use the doc.ExecutePasses to "bake" the effect of the PSR when the PSR tag is deleted. My problem is when I inserted the doc.AddUndo(), it does not work (i.e. the object does not move back the original position).
doc.ExecutePasses
You can see an illustration of the problem here: https://www.dropbox.com/s/c5b3g1f5dr0el7z/c4d183_addundo_with_doc_execute_passes.mp4?dl=0
As you can see, only the tag creation is undone but not the movement of the object. Is there a way around this? Thank you for looking at my problem
You can see the working code here:
import c4d from c4d import gui # Select two objects then execute def create_constraint(): doc = c4d.documents.GetActiveDocument() obj_sel = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER) driven = obj_sel[-1] driver = obj_sel[0] doc.StartUndo() tag = c4d.BaseTag(1019364) driven.InsertTag(tag) doc.AddUndo(c4d.UNDOTYPE_NEW, tag) tag[c4d.ID_CA_CONSTRAINT_TAG_PSR] = True tag[c4d.ID_CA_CONSTRAINT_TAG_PSR_MAINTAIN] = False tag[10001] = driver doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_0) doc.AddUndo(c4d.UNDOTYPE_CHANGE, driven) doc.EndUndo() c4d.EventAdd() if __name__=='__main__': create_constraint()
Hello,
As the document says, the UNDOTYPE_CHANGE must be called before the change.
UNDOTYPE_CHANGE
This seems to work as expected. Let me know.
import c4d from c4d import gui # Select two objects then execute def create_constraint(): doc = c4d.documents.GetActiveDocument() obj_sel = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER) driven = obj_sel[-1] driver = obj_sel[0] doc.StartUndo() doc.AddUndo(c4d.UNDOTYPE_CHANGE, driven) tag = c4d.BaseTag(1019364) driven.InsertTag(tag) doc.AddUndo(c4d.UNDOTYPE_NEW, tag) tag[c4d.ID_CA_CONSTRAINT_TAG_PSR] = True tag[c4d.ID_CA_CONSTRAINT_TAG_PSR_MAINTAIN] = False tag[10001] = driver doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_0) doc.EndUndo() c4d.EventAdd() if __name__=='__main__': create_constraint()
Cheers, Manuel
@m_magalhaes
Oh gotcha. Thanks for the reminder. Totally forgot they UNDOTYPE_CHANGE have a different placement thant UNDOTYPE_NEW
UNDOTYPE_NEW
Thanks again. Have a great day ahead!