This was a super quick script, scrambled together to unit test a larger bit of functionality.
I think it's pretty straightforward, and there's a relevant comment. So help me understand why this doesn't work. I cast selections to object types all over the place, in all kinds of code. This PARTICULAR case is nagging me hard.
I think it's pretty straightforward, and there's a relevant comment. So help me understand why this doesn't work. I cast selections to object types all over the place, in all kinds of code. This PARTICULAR case is nagging me hard.
Code:
public void Macro_FindPartParent()
{
MessageBox.Show("This function will find the Parent Object.");
Editor cEditor = CATIA.Editors.Application.ActiveEditor;
Selection cSelection = cEditor.Selection;
MessageBox.Show(Information.TypeName(cSelection.Item2(1).Value));
var e = Information.TypeName(cSelection.Item2(1).Value);
if (e == "AxisSystem")
{
MessageBox.Show("This is an AxisSystem");
// BOOM!!!
AxisSystem cAxisSystem = (AxisSystem)cSelection.Item2(1);
MessageBox.Show("" + cAxisSystem.get_Name());
}
else
{
MessageBox.Show("Not an AxisSystem");
}
}