I'd like to search through the tree in CATIA, and return the names of the parts in the tree using C#. My current code is as follows:
private void Search(object sender, EventArgs e)
{
string searchName = OriginalBox.Text;
string name;
INFITF.SelectedElement part;
//CATIA.StartCommand("Search");
try
{
Sel.Search("Name=" + searchName + "*, all");
for (int i = 1; i <= Sel.Count; i++)
{
part = Sel.Item(i);
name = part.get_Name();
MessageBox.Show(i.ToString() + " : " + name);
}
}
catch (IOException ex)
{
if (ex.Source != null)
MessageBox.Show(ex.Source);
throw;
}
}
The MessageBox displays "CATIASelectedElement45". I am receiving the message "ERROR HRESULT E_FAIL has been returned from a call to a COM component." when assigning the Sel.Item(i) to part.
How can I access the part name using Selection.Search?