You are on page 1of 3

"F30","Clamps",11,"xfvfgfdg-Y11","GR01_AF1_do_03","GR01_AF1_do_04",TRUE,0,0,"-ZG

11-Z1","-B11R1","-B11A1","GR01_AF1_di_05","GR01_AF1_di_06","-ZG11-Z2","-B11R2","
-B11A2","GR01_AF1_di_07","GR01_AF1_di_08","","","","","","","","","","","","",""
,"","","","","","","","","","","","","","","","","",3,"","","","","",""
using Tecnomatix.Engineering.Ui.Forms;
using Tecnomatix.Engineering;
public class Form1 : TxForm
{
//Edit box that will get the selection object.
private System.Windows.Forms.TextBox textBox1;
//Object in the text edit box control.
private ITxObject obj = null;
//Initialize the selection object.
private TxSelection sel = TxApplication.ActiveSelection;

private void InitializeComponent()
{
//Register to the selection events.
sel.Cleared+= new TxSelection_ClearedEventHandler(this.Form1_Cleared
);
sel.ItemsSet+= new TxSelection_ItemsSetEventHandler(this.Form1_Items
Set);
sel.ItemsAdded+=new TxSelection_ItemsAddedEventHandler(this.Form1_It
emsAdded);
sel.ItemsRemoved+= new TxSelection_ItemsRemovedEventHandler(this.For
m1_ItemsRemoved);
this.textBox1 = new System.Windows.Forms.TextBox();
}
//Selection was cleared. So, remove the text in the edit box con
trol.
private void Form1_Cleared (object sender, TxSelection_ClearedEv
entArgs e)
{
this.textBox1.Text = "";
obj = null;
}

//New objects were added into the selection.
private void Form1_ItemsAdded (object sender, TxSelection_ItemsAddedEven
tArgs e)
{
//If one object in the selection, i.e. like "Pick"
if(e.ObjectList.Count == 1)
{
obj = e.ObjectList[0];
this.textBox1.Text = obj.Name;
}
}

//Some of the selection items were removed.
private void Form1_ItemsRemoved (object sender, TxSelection_ItemsRemoved
EventArgs e)
{
//if the object in the text was one of the removed objec
t
if(e.ObjectList.Contains(obj))
{
textBox1.Text = "";
obj = null;
}
}

//Selection was set to new items.
private void Form1_ItemsSet (object sender, TxSelection_ItemsSetEventArg
s e)
{
if(e.ObjectList.Count == 1)
{
obj = e.ObjectList[0];
this.textBox1.Text = obj.Name;
}
}
}
Imports Tecnomatix.Engineering.Ui.Forms
Imports Tecnomatix.Engineering
Public Class Form1
Inherits TxForm
'Edit box that will get the selection object.
Private textBox1 As System.Windows.Forms.TextBox
'Object in the text edit box control.
Private obj As ITxObject = Nothing
'Initialize the selection object.
Private sel As TxSelection = TxApplication.ActiveSelection
Private Sub InitializeComponent()
'Register to the selection events.
sel.Cleared += New TxSelection_ClearedEventHandler(AddressOf Me.
Form1_Cleared)
sel.ItemsSet += New TxSelection_ItemsSetEventHandler(AddressOf M
e.Form1_ItemsSet)
sel.ItemsAdded += New TxSelection_ItemsAddedEventHandler(Address
Of Me.Form1_ItemsAdded)
sel.ItemsRemoved += New TxSelection_ItemsRemovedEventHandler(Add
ressOf Me.Form1_ItemsRemoved)
Me.textBox1 = New System.Windows.Forms.TextBox()
End Sub
'Selection was cleared. So, remove the text in the edit box control.
Private Sub Form1_Cleared(sender As Object, e As TxSelection_ClearedEven
tArgs)
Me.textBox1.Text = ""
obj = Nothing
End Sub
'New objects were added into the selection.
Private Sub Form1_ItemsAdded(sender As Object, e As TxSelection_ItemsAdd
edEventArgs)
'If one object in the selection, i.e. like "Pick"
If e.ObjectList.Count = 1 Then
obj = e.ObjectList(0)
Me.textBox1.Text = obj.Name
End If
End Sub
'Some of the selection items were removed.
Private Sub Form1_ItemsRemoved(sender As Object, e As TxSelection_ItemsR
emovedEventArgs)
'if the object in the text was one of the removed object
If e.ObjectList.Contains(obj) Then
textBox1.Text = ""
obj = Nothing
End If
End Sub
'Selection was set to new items.
Private Sub Form1_ItemsSet(sender As Object, e As TxSelection_ItemsSetEv
entArgs)
If e.ObjectList.Count = 1 Then
obj = e.ObjectList(0)
Me.textBox1.Text = obj.Name
End If
End Sub
End Class

You might also like