UI/ToolCommunicationSender.py
 
 
 
UI/ToolCommunicationSender.py
# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Script description:
# This tool is used with ToolCommunicationReceiver. 
# Retrieved the Receiver from the FBToolList and add a "ping" to its vertical list.
#


from pyfbsdk import *
from pyfbsdk_additions import *


# Tool creation will serve as the hub for all other controls
t = FBCreateUniqueTool("Sender")
t.StartSizeX = 400
t.StartSizeY = 400
x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
w = FBAddRegionParam(75,FBAttachType.kFBAttachNone,"")
h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
t.AddRegion("main","main", x, y, w, h)

pingcount = 0

def pingReceiver(control,event):
    if FBToolList.has_key("Receiver"):
        receiver = FBToolList["Receiver"]
        global pingcount
    
        receiver.receivedList.Items.append("ping# %d" % pingcount)  
        pingcount+= 1
    else:
        FBMessageBox( "Message", "Receiver Tool not instantiated.", "OK", None, None )

b = FBButton()
b.Caption = "Ping Receiver"
b.OnClick.Add(pingReceiver)
t.SetControl("main",b)

ShowTool(t)