Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / Getting Undo working with python scripts
  RSS 2.0 ATOM  

Getting Undo working with python scripts
Rate this thread
 
60620
 
Permlink of this thread  
avatar
  • Total Posts: 6
  • Joined: 14 September 2011 12:38 AM

Hi all,

I’ve noticed scripts do not work with Undo by default, I know an FBUndoManager() class exists, but am unsure how to use it. Has anyone seen, or know of any examples of how to use it? I’ve looked on the net but I haven’t had much luck…

Any help appreciated.

Thanks,

Steve.



Replies: 0
avatar

Thought I’d give an update. I haven’t tried hooking this up to my UI or a full procedure yet, but I got some undo functions added to the stack and working.

Demonstrates adding models inside a definition and from and external definition.

def moveMe(m):
m.Translation FBVector3d(5,5,5)
FBModelCube('cubey')
k.Show True
print 'done'
return k

FBUndoManager()
FBModelMarker('test')
m.Show True

u
.TransactionBegin('step01')
u.TransactionAddModelTRS(m)
moveMe(m)
u.TransactionAddModelTRS(k)
k.Translation FBVector3d(-5,-5,-5)
u.TransactionEnd()

u.TransactionBegin('step02')
u.TransactionAddModelTRS(m)
m.Scaling FBVector3d(5,5,5)
u.TransactionEnd()

I’m not sure how limiting the undo options will be in a practical example, manipulating layers and stuff though…

Will update in the future. Hope others find this useful.



Replies: 1
/userdata/avatar/g51ta224h.jpg

Thanks for the post and actually following up with your update :)
I was noticing the same thing on a script I was running today.  I’ll give it a shot and share my results.

Author: OmniZ3D

Replied: 24 October 2011 06:04 PM