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

I found the solution myself. I had to delcare and set the rangebox of each occurrence:

Dim oRB As Box
Set oRB = oOcc.RangeBox

 

So the entire code looks like this:

Public Sub CopySketch()

 Dim AssDoc As Inventor.AssemblyDocument
 Set AssDoc = ThisApplication.ActiveDocument
        Dim oAsmCompDef As Inventor.AssemblyComponentDefinition
        Set oAsmCompDef = AssDoc.ComponentDefinition
        Dim oOcc As ComponentOccurrence
        
        Dim CutBox As Box
       Set CutBox = AssDoc.ComponentDefinition.Occurrences.ItemByName("Cube:1").Definition.RangeBox
        For Each oOcc In oAsmCompDef.Occurrences
        
         Dim oRB As Box
        Set oRB = oOcc.RangeBox
            If oRB.IsDisjoint(CutBox) = True Then

                oOcc.Suppress
            End If
        Next

End Sub

 

Autodesk Inventor 2015 Certified Professional