Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Highligt Tangentially Connected edges on PreSelect in C#

1 REPLY 1
Reply
Message 1 of 2
Anonymous
369 Views, 1 Reply

Highligt Tangentially Connected edges on PreSelect in C#

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

 

 

1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

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

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report