After Running macro and then select part or Assemblies to Suppress

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The code below is working fine for selecting 3 parts and suppress it.
First i need to run macro and then select parts and assemblies as per my requirement by using mouse in the Inventor and then suppress it.
Can anyone please help me
' To suppress a part
Public Sub AssemblyCount()
' Set reference to active document.
' This assumes the active document is an assembly
Dim oDoc As Inventor.AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
Dim selset As SelectSet
Dim compOcc As ComponentOccurrence
oDoc.SelectSet.Clear
MsgBox ("Select a Part or a Subassembly")
Do Until oDoc.SelectSet.Count = 3
DoEvents ' Yield to other processes.
Loop
Set selset = oDoc.SelectSet
Dim obj As Object
For Each obj In selset
If TypeOf obj Is ComponentOccurrence Then
Set compOcc = obj
compOcc.Suppress
End If
Next
oDoc.SelectSet.Clear
End Sub
But i want to select multiple parts until i hit enter button after hitting enter button all the selected parts must be suppressed
I tried the Application.onkey
Public enterWasPressed As Boolean
' To suppress a part
Public Sub AssemblyCount()
' Set reference to active document.
' This assumes the active document is an assembly
Dim oDoc As Inventor.AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
Dim selset As SelectSet
Dim compOcc As ComponentOccurrence
oDoc.SelectSet.Clear
MsgBox ("Select a Part or a Subassembly")
enterWasPressed = False
Do Until enterWasPressed = True
DoEvents ' Yield to other processes.
Application.OnKey "{ENTER}", "recordEnterKeypress"
Loop
Set selset = oDoc.SelectSet
Dim obj As Object
For Each obj In selset
If TypeOf obj Is ComponentOccurrence Then
Set compOcc = obj
compOcc.Suppress
End If
Next
oDoc.SelectSet.Clear
End Sub
Sub recordEnterKeypress()
enterWasPressed = True
End Sub
but i am getting runtime error '424' object required can anyone please help me to fix my issue