I would like to select a number of parts and then run code on the selected parts, I can get one part or a specific number of parts but not any number of parts
Try oOccurrence = ThisDoc.Document.SelectSet.Item(1) Catch MessageBox.Show("Please select a component before running this rule.", "Hey!") Return End Try
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Have you looked here: Inventor Customization? I think I've seen threads on this topic there.
Ive been looking at this again and came across this... seems to work, thanks to the author
http://designandmotion.net/autodesk/replace-some-components-in-inventor-2014/
should of said, i was looking to replace some components in an assembly but not all the components
Hey Guys,
This looks like an awesome tid bit of code I'll like to use for some of our workflows but some of the functions aren't supported for Inventor 2016 use and I get error messages galore.
Could someone debug this code so it is usable in later versions? Thanks!
-Steve
As typed, the code above is meant to be used as a Rule or External Rule and not in the VBA editor/Macro environment.
Hi lazerboy,
Here's a quick redo of the code for iLogic. It creates a collection from pre-selected components and then just displays the names. You can add to it as needed.
Sub Main() 'Make a ref to active doc Dim oDoc As Document oDoc = ThisApplication.ActiveDocument 'selected components collection Dim oSelected As ObjectCollection oSelected = ThisApplication.TransientObjects.CreateObjectCollection Dim oCount As Integer oCount = oDoc.SelectSet.Count 'Check that at least 1 is selected If oCount = 0 Then 'MessageBox.Show("Please select a component.", "iLogic") Exit Sub 'bail out End If 'add to Object Collection Dim i As Long For i = 1 To oCount If oDoc.SelectSet.Item(i).Type = _ ObjectTypeEnum.kComponentOccurrenceObject Then oSelected.Add (oDoc.selectSet.Item(i)) End If Next 'do stuff to the selected files here: 'get names item name from collection For Each oItem in oSelected oMsg = oMsg & vbLf & oItem.Name Next MessageBox.Show(oCount _ & " Component(s) selected." & vbLf & oMsg, "iLogic") End Sub
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com