BasicOperations/IndividualUndoCalls.py

BasicOperations/IndividualUndoCalls.py
1 # Copyright 2009 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 #
6 # Script description:
7 # Shopw how to edit TRS property of a model with undo mecanism
8 #
9 # Topic: FBUndoManager
10 #
11 
12 from pyfbsdk import *
13 
14 #Find Model
15 lCube=FBFindModelByLabelName("Cube")
16 if not lCube:
17  lCube=FBModelCube("Cube")
18  lCube.Show = True
19 
20 if not lCube.Visibility.IsAnimated():
21  lCube.Visibility.SetAnimated(True)
22 
23 if not lCube.Visibility.IsFocused():
24  lCube.Visibility.SetFocus(True)
25 
26 lUndo = FBUndoManager()
27 
28 # Important to open our transaction
29 lUndo.TransactionBegin("vis1")
30 lUndo.TransactionAddModelTRS(lCube)
31 
32 #Key 1
33 lCube.Visibility.GetAnimationNode ().KeyAdd(FBTime(3,3,3,0),True)
34 lUndo.TransactionEnd()
35 
36 lUndo.TransactionBegin("vis2")
37 lUndo.TransactionAddModelTRS(lCube)
38 #Key 2
39 lCube.Visibility.GetAnimationNode ().KeyAdd(FBTime(0,0,0,10),True)
40 lUndo.TransactionEnd()
41 
42 lUndo.TransactionBegin("vis3")
43 lUndo.TransactionAddModelTRS(lCube)
44 #Key 3
45 lCube.Visibility.GetAnimationNode ().KeyAdd(FBTime(0,0,0,11),False)
46 lUndo.TransactionEnd()
47 
48 lUndo.TransactionBegin("vis4")
49 lUndo.TransactionAddModelTRS(lCube)
50 #Key 4
51 lCube.Visibility.GetAnimationNode ().KeyAdd(FBTime(0,0,0,20),False)
52 lUndo.TransactionEnd()
53 
54 lUndo.TransactionBegin("vis5")
55 lUndo.TransactionAddModelTRS(lCube)
56 #Key 5
57 lCube.Visibility.GetAnimationNode ().KeyAdd(FBTime(0,0,0,21),True)
58 lUndo.TransactionEnd()
59 
60 lUndo.TransactionBegin("vis6")
61 lUndo.TransactionAddModelTRS(lCube)
62 #Key 6
63 lCube.Visibility.GetAnimationNode ().KeyAdd(FBTime(0,0,0,30),True)
64 lUndo.TransactionEnd()
65 
66 lUndo.TransactionBegin("vis7")
67 lUndo.TransactionAddModelTRS(lCube)
68 #Key 7
69 lCube.Visibility.GetAnimationNode ().KeyAdd(FBTime(0,0,0,31),False)
70 lUndo.TransactionEnd()
71 
72 lUndo.TransactionBegin("vis8")
73 lUndo.TransactionAddModelTRS(lCube)
74 #Key 8
75 lCube.Visibility.GetAnimationNode ().KeyAdd(FBTime(0,0,0,40),False)
76 lUndo.TransactionEnd()
77 
78 # undo last operation
79 #lUndo.Undo()
80 #lUndo.Redo()