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

Hello @Anonymous,

 

I have adapted the code of my two previous ones @WCrihfield and @gcoombridge and created this code snippet (VBA).

Sub Hole_throuh_all_Bodies()
    Dim oCD As PartComponentDefinition
    Set oCD = ThisApplication.ActiveDocument.ComponentDefinition
    Dim oSketch As PlanarSketch
    Set oSketch = oCD.Sketches.Item("Skizze4")
    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid
    Dim oED As ExtrudeDefinition
    Set oED = oCD.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kCutOperation)
    Call oED.SetDistanceExtent("1000 mm", kNegativeExtentDirection)
    Dim oExtrude As ExtrudeFeature
    Set oExtrude = oCD.Features.ExtrudeFeatures.add(oED)
    Dim objCol1 As ObjectCollection
    Set objCol1 = ThisApplication.TransientObjects.CreateObjectCollection
    For Each oExtrude In oCD.Features.ExtrudeFeatures
        If oExtrude.Definition.Operation = kNewBodyOperation Then
            objCol1.add (oExtrude.Definition.AffectedBodies.Item(1))
        ElseIf oExtrude.Definition.Operation = kCutOperation Then
            oExtrude.SetAffectedBodies objCol1
        End If
    Next oExtrude
End Sub

 

my part bevor running the macro:

2020-02-17 14_31_53-Window.png

 

and after macro:

2020-02-17 14_32_13-Window.png

 

I hope it helps you. Maybe you can adapt it to your needs.

 

Regards,
Aleks


Aleksandar Krstic
Produkt- und Projektmanager