Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Selection using c#

p_krola
Enthusiast

Selection using c#

p_krola
Enthusiast
Enthusiast

I have a problem with selecting an item using c# 

public void SelectBody()
        {
            Face selectedBody = Pick(kPartFaceFilter);
            MessageBox.Show(selectedBody.ToString());
            MessageBox.Show("Select body");
        }

        public Face Pick(SelectionFilterEnum filter)
        {
            bool bStillSelecting = true;
            InteractionEvents oInteractEvents = inventor.CommandManager.CreateInteractionEvents();
            oInteractEvents.InteractionDisabled = false;
            SelectEvents oSelectEvents = oInteractEvents.SelectEvents;
            oSelectEvents.AddSelectionFilter(kPartFaceFilter);
            oInteractEvents.Start();
            do
            {
                inventor.UserInterfaceManager.DoEvents();

            } while (bStillSelecting);

            ObjectsEnumerator oSelectedEnts = oSelectEvents.SelectedEntities;

            oInteractEvents.Stop();

            oSelectEvents = null;
            oInteractEvents = null;

            return (Face)oSelectedEnts;
        }

 

0 Likes
Reply
Accepted solutions (1)
522 Views
5 Replies
Replies (5)

JelteDeJong
Mentor
Mentor

If I'm correct then you just want to select a face of a part. Why don't you use the built-in pick tool?

Face selectedBody = Inventor.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select as Face")

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes

p_krola
Enthusiast
Enthusiast

Currently I am converting the Fusion 360 add-in to an invetror add-in. I would like to get the same effect as in Fusion. After pressing the button, the user has the option of selecting e.g. face.

0 Likes

p_krola
Enthusiast
Enthusiast

I almost solved this problem. I can't select the model when add-in running.

0 Likes

Zach.Stauffer
Advocate
Advocate
Accepted solution

It looks like your dialog box is modal, if you're calling it using .ShowDialog() try .Show() instead.

p_krola
Enthusiast
Enthusiast
Thank you very much. I spent about 2 hours looking for a solution and it was so easy 🙂
0 Likes