Looking for help on MultiSelect :(

Looking for help on MultiSelect :(

NachoShaw
Advisor Advisor
1,526 Views
12 Replies
Message 1 of 13

Looking for help on MultiSelect :(

NachoShaw
Advisor
Advisor

Hi

 

Please please can someone help or point me in the general direction (NOT API because infor isnt there). Im not asking for much, just a bit of help....

 

1. I need to be able to select multiple parts in an assembly by clicking them. The parts that are clicked need to stay highlighted so that i can process them in a routine. (i have tried the oSelect Class which is ok but cancels the selection after each clicked item

 

2. i need to be able to select ALL occurrences of a part in an assembly. If there are 7 occurrences of the same part, i need to select them and add them to a selectset.

 

In the assembly, i am looking the kLeafAssemblyOccurence which is what i need. i am also looking at doc.SelectSet.SelectMultiple (myObject)

 

i just cannot get it working and i fear a trip to the wig shop due to pull my own hair out lol.....

 

 

 

Please can anyone give me a general pointer or a bit of help?

 

 

 

Thanks

 

 

Nigel

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
1,527 Views
12 Replies
Replies (12)
Message 2 of 13

rjay75
Collaborator
Collaborator

1. Ok I will give you an example and point you to the api under the section Interacting with the User, and the sample Basic Selection Using Interaction Events API Sample.

 

Here's a sample in C# of the basic pattern I use for interactive selecting.

 

        private InteractionEvents objInteraction;
        private SelectEvents sle;
        private UserInputEvents uiecc;
        private bool curSelection = false;
 
        public void StartGetObjects()
        {
            sle = null;
            objInteraction = null;
            objInteraction = appInventor.CommandManager.CreateInteractionEvents();
            sle = objInteraction.SelectEvents;
            sle.ResetSelections();
            sle.ClearSelectionFilter();
            sle.SingleSelectEnabled = false;
            sle.AddSelectionFilter(SelectionFilterEnum.kAssemblyOccurrenceFilter);
            objInteraction.StatusBarText = "Select Components";
            //objInteraction.SetCursor(CursorTypeEnum.kCursorBuiltInSelectArrow);
            curSelection = true;
            
            pckAdd.btnDonePick.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(btnDonePick_OnExecute);
            sle.OnSelect += new SelectEventsSink_OnSelectEventHandler(sle_OnSelect);
            sle.OnUnSelect += new SelectEventsSink_OnUnSelectEventHandler(sle_OnUnSelect);
            objInteraction.Start();
        }
 
        private void sle_OnUnSelect(ObjectsEnumerator UnSelectedEntities, SelectionDeviceEnum SelectionDevice,
    Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
        {
            if(curSelection)
            {
            //Can remove selected entities from an ObjectCollection or list
            }
        }
 
        private void sle_OnSelect(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice,
            Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
        {
            if(curSelection)
            {
            //Can add selected entities to an ObjectCollection or list
            }
        }
 

 

First set object filters/options and subscribe to the events on selecting and unselecting. Start the interactive selection session, Save/Remove objects as they are selected. The variable curSelection is true while I'm in selection mode. I have a button that sets that value to false and stops the selection process.

 

Or when I don't need it to be interactive, I use the Document.SelectSet object and have to workflow of the command be the objects must be preselected.

 

A select set doesn't need to be used to hold a collection of objects. Use an ObjectCollection. See TransientObjects.CreateObjectCollection(). 

 

2. Just loop through all the occurences in an assembly testing to see if they are the part you want and if so add them to a list or ObjectCollection.

0 Likes
Message 3 of 13

NachoShaw
Advisor
Advisor
Hi

Thanks for your reply. I'm programming in .net and testing routines in vba. I'll see if I can convert from C# to .net. Regarding the api, when I search collection, I get no results. I found the simple sielection sample and I'll see if I can expand on that. Up until now, I cannot get a selected multiple set that remains highlighted but perseverance is one of my strong points lol



Thanks

Nigel

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
Message 4 of 13

rjay75
Collaborator
Collaborator
Are you using VB.NET, if so you can try using a C# to VB converter to get you halfway there.

What version of Inventor are you using. In the 2013 API help the sample is under Sample Programs > Parts > General > Basic Selection Using Interaction Events.

Also if you look up the InteractionEvents Object it has a link to the sample on it.
Message 5 of 13

NachoShaw
Advisor
Advisor

Hi

Yes i am using vb.net

 

i'll update as i progress

 

 

 

 

thanks

 

 

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
Message 6 of 13

NachoShaw
Advisor
Advisor

Hi

 

most of it converted and i understand a lot of it however, i am erroring on parts. it looks like a button is created but i cannot see what function it calls.

 

pckAdd.btnDonePick.OnExecute += New ButtonDefinitionSink_OnExecuteEventHandler(btnDonePick_OnExecute)

sle.OnSelect += New SelectEventsSink_OnSelectEventHandler(sle_OnSelect)
sle.OnUnSelect += New SelectEventsSink_OnUnSelectEventHandler(sle_OnUnSelect)

 

 

Also, if i try and change these to Sub routines, i get errors

 

Private  sub sle_OnUnSelect(ObjectsEnumerator Property SelectionDevice,() As UnSelectedEntities,SelectionDeviceEnum
        End Sub
 
        Private sle_OnSelect(ObjectsEnumerator Property SelectionDevice,() As JustSelectedEntities,SelectionDeviceEnum
        End Sub

 

Thanks

 

 

 

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
Message 7 of 13

rjay75
Collaborator
Collaborator

I have a button created else where that the command temporarily uses. It's a Done button the user can pick to signal when they are done selecting.

 

When the button is clicked it stops the interaction events, turns off the selecting flag, and calls the method that does the work passing the selected objects, and other clean up.

 

The two select event handlers should have the signature of

 

        Private Sub sle_OnUnSelect(UnSelectedEntities As ObjectsEnumerator, SelectionDevice As SelectionDeviceEnum, ModelPosition As Inventor.Point,ViewPosition As Point2d,View As Inventor.View)
            IcurSelection
            End If
        End Sub
 
        Private Sub sle_OnSelect(JustSelectedEntities As ObjectsEnumerator, SelectionDevice As SelectionDeviceEnum,ModelPosition As Inventor.Point,ViewPosition As Point2d,View As Inventor.View)
            IcurSelection
            End If
        End Sub

 

 

0 Likes
Message 8 of 13

NachoShaw
Advisor
Advisor
Hi

Thanks for that. I have converted it and it al works quietly nicely 🙂

Would you be able to give me a little extra pointer on how to pass the collection of parts to a function to run a few custom updates? It's just the looping of each part in the collection that I am struggling with. I am using Component Occurence. I can run the routine I have with a selected part, I can't quite get the collected selection set to do the same thing


Thanks for your help 🙂



Nigel

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
Message 9 of 13

rjay75
Collaborator
Collaborator

What does the signature of the function you're calling to do work on the parts look like? Ideally you would change it to accept the collection of parts you have picked. Instead of the SelectionSet you use the Collection of Parts.

 

What type of collection are you using?

0 Likes
Message 10 of 13

NachoShaw
Advisor
Advisor

Hi

 

Thanks for your reply. My function is a simple routine to split 1 part from another (where i place one into another). everything processed is a simple rectangle part (think plywood because thats what it is lol).

 

My intention is to select all of the parts that need to be split in a single process and once selected, run the routine to split the tool part. this is a single part that splits. the routine works fine with a single selection of part then tool but i cannot get the selected collection to do the same..

 

does that make sense lol?

 

 

Thanks

 

Nigel

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
Message 11 of 13

NachoShaw
Advisor
Advisor
Hi

I am using your code to make the selection and I'm adding to a SelectSet.MultipleSelect. Not entirely sure how to make a collection instead and process it. 🙂


Thanks


Nigel

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
Message 12 of 13

rjay75
Collaborator
Collaborator

You need to have a collection to add/remove items to as they are selected in the Select events.

 

One way to do is like this.

 

 
Dim objSelectSet as ObjectCollection = appInventor.TransientObject.CreateObjectCollection()
 
Private Sub sle_OnUnSelect(UnSelectedEntities As ObjectsEnumerator,SelectionDevice As SelectionDeviceEnum, ModelPosition As Inventor.Point,ViewPosition As Point2d,View As Inventor.View)
   If curSelection
      'Remove Object from Collection
      If UnSelectedEntities.Count > 0 Then
         For Each obj As Object In UnselectedEntities
            objSelectSet.Remove(obj)
         Next
      End If
   End If
End Sub
 
Private Sub sle_OnSelect(JustSelectedEntities As ObjectsEnumerator,SelectionDevice As SelectionDeviceEnum,ModelPosition As Inventor.Point,ViewPosition As Point2d,View As Inventor.View)
   If curSelection
      'Add Objects to Collection
      If JustSelectedEntities.Count > 0 Then
         For Each obj As Object In JustSelectedEntities
            objSelectSet.Add(obj)
         Next
      End If
   End If
End Sub

 

 

Then pass the objCollection object to whatever function needs the collection.

0 Likes
Message 13 of 13

Anonymous
Not applicable

Hi rjay75

 

pckAdd.btnDonePick.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(btnDonePick_OnExecute);
            sle.OnSelect += new SelectEventsSink_OnSelectEventHandler(sle_OnSelect);
            sle.OnUnSelect += new SelectEventsSink_OnUnSelectEventHandler(sle_OnUnSelect);

 

0 Likes