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: 

VBA - Prompt User for Selection

1 REPLY 1
SOLVED
Reply
Message 1 of 2
whiteskulleton
2553 Views, 1 Reply

VBA - Prompt User for Selection

Hello,

I need some help with some code that I am writing on VBA with Autodesk Inventor Professional 2014 and I want to prompt the user for a selection. I am in the assembly environment and have generated a frame with the frame generator. I want to ask the user to select some frame components so I can do something with them. What I really want is a similar selection functionality as the frame generator. More specifically, I want it to be similar to the multi-select function that appears when you edit a frame member. Take a look at the picture.

 

Multi-Select.png

 

For the action that I want to preform with the code, the user will usually have to select multiple frame members. I have tried this code:

Sub SelectingAnOccurrence()
    'Set a reference to the inventor application.
    Dim oApp As Application
    Set oApp = ThisApplication

    ' Set a reference to the active assembly document.
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument

    ' Prompt user to pick an occurrence
    Dim oOcc As ComponentOccurrence
    Set oOcc = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Pick occurrence to do something with")

End Sub

 The thing is, however, that it only selects the Frame0001:1 Assembly when I click on a member from the graphics window. I can select each individual member in the tree but I would like to select the individual members in the graphics window. What I want is the "Part Priority" selection filter to replace the kAssemblyOccurrenceFilter in the code. The problem is that I can't find the selection filter that does this from within VBA.

 

I also want a form like the frame generator that updates as frame members are selected. In the frame generator, you can select multiple frames and the information updates. I want to be able to select frame members and have a form populate stuff based on the members that I select. Right now, I can't interact with inventor while a form is visible.

 

It would also be helpful to enable pre-highlight only on the frames that have a certain custom iProperty or those that are in a certain family. I want to be able to only have a pre-highlight of all the frame members in the assembly with that certain custom iProperty. I know I can select the component and then check to see if it has the property. If it doesn't then it will be deselected. What I am wondering is if there is a setting that prevents the selection or pre-highlighting of all the components except those which have the custom iProperty.

 

Finally, I am wondering if I have to go to the next level and make a custom add-in. While that would let me do all of this, I want to try and keep it at the VBA level.

 

Thanks for reading and any help would be appreciated.

1 REPLY 1
Message 2 of 2
rogmitch
in reply to: whiteskulleton

Have you tried 'kAssemblyLeafOccurrenceFilter' for the pick function.  It will highlight individual parts

 

If you want to interact with Inventor you need something like 

 

YourForm.Show (vbModeless) 

 

All the best 

 

Roger Mitchell

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

Post to forums  

Autodesk Design & Make Report