Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

After Running macro and then select part or Assemblies to Suppress

Anonymous

After Running macro and then select part or Assemblies to Suppress

Anonymous
Not applicable

 

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

0 Likes
Reply
371 Views
1 Reply
Reply (1)

adam.nagy
Autodesk Support
Autodesk Support

This seems like a duplicate of http://forums.autodesk.com/t5/inventor-customization/suppress-multiple-part-using-vba/m-p/5680580#U5...

 

Please do not log the same things multiple times, instead you can just update them.



Adam Nagy
Autodesk Platform Services
0 Likes