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

How can I make a hole through multiple solid bodies with VBA?

 

In the code below, I tried to make a hole through a feature and a derived component. The hole only ever goes through a solid.
Is there someone who has a snippet of code for me with which you can make a hole through several solid bodies?

 

Sub X()

Dim oCD As PartComponentDefinition
Set oCD = ThisApplication.ActiveDocument.ComponentDefinition

Dim oSketch As PlanarSketch
oSketch = oCD.Sketches.Item(2)

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)

End Sub

holeThroughMultipleBodies.png