Hi Georg,
Here is an update to the code that resolves the problem when copying hole 13 when the target hole has threads. (hole 40)
It also now uses the TargetHole.Extent.Direction instead of the SourceHole.Extent.Direction. Seems to get the correct results.
Public Sub Modify_Holes_2()
Dim invDoc As Document
Set invDoc = ThisApplication.ActiveDocument
Dim SourceHole As Object
Dim TargetHole As HoleFeature
Dim oHoles As HoleFeatures
Set oHoles = invDoc.ComponentDefinition.Features.HoleFeatures
' Set SourceHole = oHoles("Hole11")
Set SourceHole = oHoles("Hole13")
' Set SourceHole = oHoles("Hole40")
For Each TargetHole In oHoles
' Debug.Print SourceHole.name
Debug.Print TargetHole.name
If SourceHole.Tapped = False And TargetHole.Tapped = True Then
TargetHole.Tapped = False
TargetHole.HoleDiameter.value = SourceHole.HoleDiameter.value
End If
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 = kThroughAllExtent Then Call TargetHole.SetThroughAllExtent(TargetHole.Extent.Direction)
If SourceHole.ExtentType = kDistanceExtent Then
If SourceHole.FlatBottom = True Then
'Call TargetHole.SetDistanceExtent(SourceHole.Extent.Distance.value, SourceHole.Extent.Direction, True)
Call TargetHole.SetDistanceExtent(SourceHole.Extent.Distance.value, TargetHole.Extent.Direction, True)
Else
'Call TargetHole.SetDistanceExtent(SourceHole.Extent.Distance.value, SourceHole.Extent.Direction, False, SourceHole.BottomTipAngle.value)
Call TargetHole.SetDistanceExtent(SourceHole.Extent.Distance.value, TargetHole.Extent.Direction, False, 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
End If
invDoc.Update
Next
End Sub
Thanks,
Wayne
Wayne Brill
Developer Technical Services
Autodesk Developer Network