from pyfbsdk import *
from pyfbsdk_additions import *

region1 = FBLabel()
edtStart = FBEditNumber()
edtStop = FBEditNumber()
edtStep = FBEditNumber()
region5 = FBButton()

def BtnCallbackregion5(control, event):
	startF = int(edtStart.Value)
	stopF = int(edtStop.Value)
	stepF = int(edtStep.Value)
	time = FBTime()
	lChar = FBApplication().CurrentCharacter
	for i in range(startF, stopF, stepF):
	    time.SetTime(0,0,0, i)
	    FBPlayerControl().Goto(time)
	    FBSystem().Scene.Evaluate()
	    pose = FBCharacterPose( str(i) )
	    pose.CopyPose( lChar )


def PopulateTool(t):
	#populate regions here

	x = FBAddRegionParam(15,FBAttachType.kFBAttachNone,"")
	y = FBAddRegionParam(15,FBAttachType.kFBAttachNone,"")
	w = FBAddRegionParam(275,FBAttachType.kFBAttachNone,"")
	h = FBAddRegionParam(15,FBAttachType.kFBAttachNone,"")
	t.AddRegion("region1","region1", x, y, w, h)

	t.SetControl("region1", region1)
	region1.Visible = True
	region1.ReadOnly = False
	region1.Enabled = True
	region1.Hint = ""
	region1.Caption = "Snapshot character animation from start to stop by step"
	region1.Style = FBTextStyle.kFBTextStyleNone
	region1.Justify = FBTextJustify.kFBTextJustifyLeft
	region1.WordWrap = True
	
	x = FBAddRegionParam(15,FBAttachType.kFBAttachNone,"")
	y = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
	w = FBAddRegionParam(110,FBAttachType.kFBAttachNone,"")
	h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
	t.AddRegion("edtStart","edtStart", x, y, w, h)

	t.SetControl("edtStart", edtStart)
	edtStart.Visible = True
	edtStart.ReadOnly = False
	edtStart.Enabled = True
	edtStart.Hint = ""
	edtStart.Value = 0.000000
	edtStart.Min = 0.000000
	edtStart.Max = 299.000000
	edtStart.Precision = 0.000000
	edtStart.LargeStep = 2.000000
	edtStart.SmallStep = 1.000000
	
	x = FBAddRegionParam(140,FBAttachType.kFBAttachNone,"")
	y = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
	w = FBAddRegionParam(105,FBAttachType.kFBAttachNone,"")
	h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
	t.AddRegion("edtStop","edtStop", x, y, w, h)

	t.SetControl("edtStop", edtStop)
	edtStop.Visible = True
	edtStop.ReadOnly = False
	edtStop.Enabled = True
	edtStop.Hint = ""
	edtStop.Value = 70.000000
	edtStop.Min = 0.000000
	edtStop.Max = 417.000000
	edtStop.Precision = 1.000000
	edtStop.LargeStep = 2.000000
	edtStop.SmallStep = 1.000000
	
	x = FBAddRegionParam(260,FBAttachType.kFBAttachNone,"")
	y = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
	w = FBAddRegionParam(95,FBAttachType.kFBAttachNone,"")
	h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
	t.AddRegion("edtStep","edtStep", x, y, w, h)

	t.SetControl("edtStep", edtStep)
	edtStep.Visible = True
	edtStep.ReadOnly = False
	edtStep.Enabled = True
	edtStep.Hint = ""
	edtStep.Value = 5.000000
	edtStep.Min = 0.000000
	edtStep.Max = 476.000000
	edtStep.Precision = 1.000000
	edtStep.LargeStep = 2.000000
	edtStep.SmallStep = 1.000000
	
	x = FBAddRegionParam(15,FBAttachType.kFBAttachNone,"")
	y = FBAddRegionParam(85,FBAttachType.kFBAttachNone,"")
	w = FBAddRegionParam(105,FBAttachType.kFBAttachNone,"")
	h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
	t.AddRegion("region5","region5", x, y, w, h)

	t.SetControl("region5", region5)
	region5.Visible = True
	region5.ReadOnly = False
	region5.Enabled = True
	region5.Hint = ""
	region5.Caption = "Pose It!"
	region5.State = 0
	region5.Style = FBButtonStyle.kFBPushButton
	region5.Justify = FBTextJustify.kFBTextJustifyLeft
	region5.Look = FBButtonLook.kFBLookNormal
	region5.OnClick.Add(BtnCallbackregion5)
	
def CreateTool():
	t = CreateUniqueTool("Tool")
	t.StartSizeX = 400
	t.StartSizeY = 151
	PopulateTool(t)
	ShowTool(t)
CreateTool()
