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: 

Selectset

7 REPLIES 7
Reply
Message 1 of 8
NachitoMax
609 Views, 7 Replies

Selectset

Hi

Can anyone help messing a bit of code to select a set? In my assembly, I need to create 2 groups of selected objects. I can apply attributes to anything selected but I cannot seem to get my code right that allows me to click on parts and add them to a select set.

Any help appreciated




Nige

Nacho

Automation & Design Engineer

Inventor Programmer (C#, VB.Net / iLogic)


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.


7 REPLIES 7
Message 2 of 8
adam.nagy
in reply to: NachitoMax

Hi,

 

In the Inventor API Help file (C:\Program Files\Autodesk\Inventor 2014\Local Help\admapi_18_0.chm) did you go through the section "Inventor API's User Manual >> Customizing the User Interface >> Interacting with the User"?

 

Did you try "oSelectEvents.AddSelectionFilter kAssemblyOccurrenceFilter"?

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 3 of 8
YuhanZhang
in reply to: NachitoMax

Not quite sure what problem you encountered,can you explain more about what you want to do?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 4 of 8
NachitoMax
in reply to: YuhanZhang

Hi

Thanks for the reply. what iam actually trying to do is -

 

1. Let user select parts in assembly that need treatment. These parts will all be highlighted and added to a collection

2. Let user select a part and once clicked, all occurences are added to a collection (Doesnt need to visually highlight, just be a collection)

3. i have a routine that deals with 2 parts -

 

Dim oOccurrence1 As ComponentOccurrence

Dim oOccurrence2 As ComponentOccurrence

 

i need to loop through the 1st collection and pass each object to oOccurrence1. for every object, loop through the 2nd collection

 

Does that make any sense? basically, for each object in the first collection, loop through all objects in the second selection

 

 

 

Thanks

 

Nigel

 

 

Nacho

Automation & Design Engineer

Inventor Programmer (C#, VB.Net / iLogic)


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.


Message 5 of 8
YuhanZhang
in reply to: NachitoMax

Understand now, you can refer to the "Inventor API's User Manual >> Customizing the User Interface >> Interacting with the User" in API help as Adam pointed. For you workflow you need to monitor the selection event, and the manual can tell you how to do that. Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 6 of 8
NachitoMax
in reply to: YuhanZhang

Hi

It's not the selection I am struggling with as I can select multiple parts and add them to an object collection, I am struggling with passing each part in the collection to a routine that uses ComponentOccurrence.

My Routine that carries out the process uses

BaseOcc As ComponentOccurrence
Set BaseOcc = 'currently uses a select event

I have a public collection variable called M_Collection. I cannot work out how to loop through my collection and pass each object to my routine using ComponentOccurrence.


Thanks


Nacho

Automation & Design Engineer

Inventor Programmer (C#, VB.Net / iLogic)


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.


Message 7 of 8
adam.nagy
in reply to: NachitoMax

"I cannot work out how to loop through my collection and pass each object to my routine using ComponentOccurrence."

What object type you are using for collecting objects? Inventor's ObjectCollection class created through TransientObjects.CreateObjectCollection()?

 

Most collections support For Each loop that gets back each object and then you can call your other function by passing in that object as a parameter.

 

Sub MyFunction(BaseOcc As ComponentOccurrence)
  ' Do something with BaseOcc
End Sub

Sub Main
  Dim coll As ObjectCollection
  Set coll = ThisApplication.TransientObjects.CreateObjectCollection

  ' Fill the collection with various component occurrences ...

  Dim o As Object
  For Each o In coll
    Call MyFunction(o)
  Next
End Sub


Adam Nagy
Autodesk Platform Services
Message 8 of 8
rjay75
in reply to: NachitoMax

Hi Nigel, if this is still part of the selection process you were doing before you need to loop through your collections together. This will assume you have two ObjectCollections named objSelectSet1 and objSelectSet2, and that all the objects in the collections are ComponentOccurrences

 

The declarations are not needed as they will be in your looping construct.

 

Remove: Dim oOccurrence1 As ComponentOccurrence

Remove: Dim oOccurrence2 As ComponentOccurrence

 

You will need nested loops.

 

For Each oOcurrence1 As ComponentOccurrence In objSelectSet1

    For Each oOcurrence2 As ComponentOccurrence In objSelectSet2

        'Do what you need to do here

    Next

Next 

 

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

Post to forums  

Autodesk Design & Make Report