02-17-2020
05:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-17-2020
05:36 AM
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:
and after macro:
I hope it helps you. Maybe you can adapt it to your needs.
Regards,
Aleks