from pyfbsdk import *
1 获取character controls的character的名字
FullName = FBApplication().CurrentCharacter.FullName
Name = FBApplication().CurrentCharacter.Name
2 选择当前模型character control的character
# 新建一个列表
ComponentList = FBComponentList()
# 把NS:Character放到ComponentList列表中
FBFindObjectsByName('NS:Character', ComponentList, True, False)
# 找参数可以打印出来查看的几个参数
MilaCharacter = ComponentList[0]
# 选中NS:Character
MilaCharacter.Selected = True
3 获取并截取take名字
Takename = FBSystem().CurrentTake.Name
4 查找并选中
Node= FBFindModelByLabelName(‘Role:Name’)
# 选中
Node.Selected = True
5 K帧(旋转、位移)
Node.Translation.Key()
Node.Rotation.Key()
6 从开始帧播放
FBPlayerControl().GotoStart()
FBPlayerControl().Play()
7 获取首尾帧
Syst= FBSystem()
# 首帧
StartTime = Syst.CurrentTake.LocalTimeSpan.GetStart()
StartFrame = Syst.CurrentTake.LocalTimeSpan.GetStart().GetFrame()
# 尾帧
EndTime = Syst.CurrentTake.LocalTimeSpan.GetStop()
EndFrame = Syst.CurrentTake.LocalTimeSpan.GetStop().GetFrame()
8 从尾帧回到首帧
FBPlayerControl().GotoStart()
FBPlayerControl().Stop()
9 获取度数,查找节点(Rotation为例)
RotationNode = Node.Rotation.GetAnimationNode()
# 获取RotationNode节点的值(Nodes下标表示X,Y,Z;Keys下标表示第几帧)
Num = RotationNode.Nodes[0].FCurve.Keys[EndFrame].Value
# 删除RotationNode节点的某一轴(0--x,1--y,2--z)
RotationNode.Nodes[1].FBDelete()
10 修改旋转度数(旋转Y轴为例)
Nameref.Rotation = FBVector3d( 90, 0, -Num)
11 选中position----properties----position----constrain Axes(Affect Y为例)
AffectZProp = constraint.PropertyList.Find( 'AffectY' )
# 选择
AffectZProp.Data = True
12 渲染(plot all…)
# 对plot all属性进行设置并plot
lOptions = FBPlotOptions()
lOptions.PlotAllTakes = False
lOptions.PlotOnFrame = True
lOptions.PlotPeriod = FBTime( 0, 0, 0, 1 ) # 表示首帧
lOptions.PlotLockedProperties = True
lOptions.UseConstantKeyRedu