Hi
I have been working on a userdata button that places a preset in the environment, I also wanted to put it inside the end of a joint, my problem is that when performing these steps, when going back the preset is outside the joint, the code generates the preset and then place it inside the board, is there a way to do it directly?
Solved preset children of objects?
Hi,
you should start the undo before merging the "preset" you want to add, and add the document to its own undo stack. just like this
doc.StartUndo()
doc.AddUndo(c4d.UNDOTYPE_CHANGE, doc)
res = c4d.documents.MergeDocument(doc,"file",c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS)
By the way you should never use "magic number" instead of flags. In that case SCENEFILTER_OBJECTS | SCENEFILTER_MATERIALS is the same as 3. There's no flag that have the value of 4 so 7 mean nothing more than 3.
Cheers,
Manuel
MAXON SDK Specialist
Hi,
If i understand, you have two undo stack? Or must press twice undo to retrieve the document as it was before pressing the button?
sharing some code would help a bit. I'm not sure how you add the object in the scene and how you create your new entry in the undo stack.
Cheers,
Manuel
MAXON SDK Specialist
@m_magalhaes
Hi
in itself the problem is that when performing the complete action when going back the object is outside the father, since it was first created and later placed inside the father
import c4d
from c4d import documents, plugins
def main():
c4d.documents.MergeDocument(doc,"file location",7) #the preset has already been added
doc.StartUndo()
child = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_NONE)
for A in child:
doc.AddUndo(c4d.UNDOTYPE_CHANGE, A)
A.InsertUnder(father)#the parent would be defined by a link
doc.EndUndo()
c4d.EventAdd()
I did this since when adding the preset it is already selected, use this to place it inside another object
Hi,
you should start the undo before merging the "preset" you want to add, and add the document to its own undo stack. just like this
doc.StartUndo()
doc.AddUndo(c4d.UNDOTYPE_CHANGE, doc)
res = c4d.documents.MergeDocument(doc,"file",c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS)
By the way you should never use "magic number" instead of flags. In that case SCENEFILTER_OBJECTS | SCENEFILTER_MATERIALS is the same as 3. There's no flag that have the value of 4 so 7 mean nothing more than 3.
Cheers,
Manuel
MAXON SDK Specialist