This "copies" hole parameters from a source hole to multiple target holes:
Public Sub CopyHoleSettings()
Dim InvDoc As Document
Set InvDoc = ThisApplication.ActiveEditDocument
Dim SourceHole As Object
Dim TargetHole As Object
Dim More As Boolean
Set SourceHole = ThisApplication.CommandManager.Pick(kPartFeatureFilter, "Select SOURCE hole! (ESC to abort)")
If (Not SourceHole Is Nothing) Then
If SourceHole.Type = kHoleFeatureObject Then
Set TargetHole = Nothing
More = True
Do Until More = False
Set TargetHole = ThisApplication.CommandManager.Pick(kPartFeatureFilter, "Select TARGET hole! (ESC to abort)")
If (Not TargetHole Is Nothing) Then
If TargetHole.Type = kHoleFeatureObject Then
If SourceHole.HoleType = kCounterBoreHole Then Call TargetHole.SetCBore(SourceHole.CBoreDiameter.Value, SourceHole.CBoreDepth.Value)
If SourceHole.HoleType = kCounterSinkHole Then Call TargetHole.SetCSink(SourceHole.CSinkDiameter.Value, SourceHole.CSinkAngle.Value)
If SourceHole.HoleType = kSpotFaceHole Then Call TargetHole.SetSpotFace(SourceHole.SpotFaceDiameter.Value, SourceHole.SpotFaceDepth.Value)
If SourceHole.HoleType = kDrilledHole Then Call TargetHole.SetDrilled
If SourceHole.ExtentType = kThroughAllExtent Then Call TargetHole.SetThroughAllExtent(SourceHole.Extent.Direction)
If SourceHole.ExtentType = kDistanceExtent Then
If SourceHole.FlatBottom = True Then
Call TargetHole.SetDistanceExtent(SourceHole.Extent.Distance.Value, SourceHole.Extent.Direction, True)
Else
Call TargetHole.SetDistanceExtent(SourceHole.Extent.Distance.Value, SourceHole.Extent.Direction, Fales, SourceHole.BottomTipAngle.Value)
End If
End If
If SourceHole.ExtentType = kToExtent Then
Call TargetHole.SetEndOfPart(True)
Call TargetHole.SetToFaceExtent(SourceHole.Extent.ToEntity.Item(1), SourceHole.Extent.ExtendToFace)
Call InvDoc.ComponentDefinition.SetEndOfPartToTopOrBottom(False)
End If
If SourceHole.Tapped = True Then
If SourceHole.TapInfo.FullTapDepth = True Then
TargetHole.TapInfo = InvDoc.ComponentDefinition.Features.HoleFeatures.CreateTapInfo(SourceHole.TapInfo.RightHanded, SourceHole.TapInfo.ThreadType, SourceHole.TapInfo.ThreadDesignation, SourceHole.TapInfo.Class, True)
Else
TargetHole.TapInfo = InvDoc.ComponentDefinition.Features.HoleFeatures.CreateTapInfo(SourceHole.TapInfo.RightHanded, SourceHole.TapInfo.ThreadType, SourceHole.TapInfo.ThreadDesignation, SourceHole.TapInfo.Class, False, SourceHole.TapInfo.ThreadDepth.Value)
End If
TargetHole.Tapped = True
Else
TargetHole.Tapped = False
TargetHole.HoleDiameter.Value = SourceHole.HoleDiameter.Value
End If
InvDoc.Update
End If
Else
More = False
End If
Loop
End If
End If
End Sub
Needs a little more error checking and stuff. Also, ToFace extent holes may or may not work, depending on where the target hole is in relation to the ToFace. G-Threads won't work either since they don't have a Class. (Autodesk should really fix this.)