Hi,
Based on the "interactive selection" example in the programmers help, i have tried to implement the highligting og Tangentially connected edges in the OnPreSelect Event. I have followed the sample VB code, however it still doesn't work. I am no getting any error messages, but the tangentially connected edges are not highlighted. What am i doing wrong? Here's the code:
public override void OnPreSelect(object preSelectEntity, out bool doHighlight, ObjectCollection morePreSelectEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, Inventor.View view) { doHighlight = true; try { if (preSelectEntity is Edge) { Edge preSelectEdge = (Edge)preSelectEntity; EdgeCollection TangentiallyConnected = preSelectEdge.TangentiallyConnectedEdges; int ntangents = TangentiallyConnected.Count; if (ntangents > 1) { morePreSelectEntities = m_application.TransientObjects.CreateObjectCollection(null); for (int n = 1; n <= ntangents; n++) { if (TangentiallyConnected[n] != preSelectEdge) { morePreSelectEntities.Add((object)TangentiallyConnected[n]); } } } doHighlight = true; } else { doHighlight = false; } } catch (Exception e) { doHighlight = false; System.Windows.Forms.MessageBox.Show(e.ToString()); } }
I have checked and verified that the "TangentiallyConnectedEdges" property does indeed have tangentially connected edges, and i can access each of them, but they just won't show up highlighted inside Inventor.
Hope someone has a suggestion! I would really appreciate it!
/ Dan
Hi again,
I got the problem solved. I used the "CustomCommand" Add In sample from the Inventor SDK as a skeleton for my own Add In, and it turned out that a simple "ref" was missing in the "OnPreSelect" event calback in the "Interaction" class:
public void SelectEvents_OnPreSelect (ref object preSelectEntity, out bool doHighlight, ref ObjectCollection morePreSelectEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, View view) { m_parentCmd.OnPreSelect(preSelectEntity, out doHighlight, morePreSelectEntities, selectionDevice, modelPosition, viewPosition, view); }
Should be:
public void SelectEvents_OnPreSelect (ref object preSelectEntity, out bool doHighlight, ref ObjectCollection morePreSelectEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, View view) { m_parentCmd.OnPreSelect(preSelectEntity, out doHighlight, ref morePreSelectEntities, selectionDevice, modelPosition, viewPosition, view); }
Yes, rather obvious, however a small mistake that is easily looked over when you are an inexperienced programmer 🙂
// DGadensg