How deep is a hole or thread ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hmm
sometimes i dont understand the API.
i only want to get he depht of a hole (or threaded one).
Attached a sample part and here my code.
If the option is through all i never get a value
*********************
Public Sub KC_CAM_FEATURES_2()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
Set oDef = oPartDoc.ComponentDefinition
Dim oPartFeature As PartFeature
Set oPartFeature = oDef.Features.Item(1)
Dim Feat_Index_bevels As Integer
Feat_Index_bevels = 0
Dim Feat_Index_holes As Integer
Feat_Index_holes = 0
Dim Feat_Index_threads As Integer
Feat_Index_threads = 0
Dim Hole_all As Integer
Hole_all = 0
Dim act_Bevel As Inventor.ChamferFeature
Dim act_bevel_str1 As String
Dim act_bevel_str2 As String
Dim act_bevel_str3 As String
Dim act_bevel_target_str As String
Dim act_Hole As Inventor.HoleFeature
Dim act_Hole_faces As Faces
Dim act_Hole_faces_depht As Variant
Dim act_Hole_thread As Variant
Dim holethere, bevelthere, threadthere As Boolean
Dim Feat_name As String
Feat_name = ""
For Each oPartFeature In oDef.Features
If Not oPartFeature.Suppressed = True Then
oPartFeature.SetEndOfPart (True)
If oPartFeature.Type = kChamferFeatureObject Then
Feat_Index_bevels = Feat_Index_bevels + 1
Debug.Print "CHAMFER FOUND INDEX = " & Feat_Index_bevels
ElseIf oPartFeature.Type = kHoleFeatureObject Then
Set act_Hole = oPartFeature
'THREAD
If act_Hole.Tapped = True Then
Feat_Index_threads = Feat_Index_threads + 1
Debug.Print "THREADED HOLE FOUND INDEX = " & Feat_Index_threads
'****************************************************************
Feat_name = ""
Dim oNewTapInfo As HoleTapInfo
Set oNewTapInfo = act_Hole.TapInfo
Debug.Print "KC_THREAD|" & oNewTapInfo.CustomThreadDesignation & "|T=" & oNewTapInfo.ThreadDepth.Expression & "|D=" & oNewTapInfo.TapDrillDiameter & "mm" & "|T="
Feat_name = "KC_THREAD|" & oNewTapInfo.CustomThreadDesignation & "|T=" & oNewTapInfo.ThreadDepth.Expression & "|D=" & oNewTapInfo.TapDrillDiameter & "mm" & "|T="
Feat_Index_threads = Feat_Index_threads + 1
oPartFeature.name = Feat_name
threadthere = True
Else
'NORMAL HOLE
Feat_Index_holes = Feat_Index_holes + 1
Dim Hinfo As String
Hinfo = act_Hole.ExtendedName
Debug.Print "KC_HOLE_" & Feat_Index_holes & "|D=" & CStr(act_Hole.HoleDiameter.Expression & "|T=" & Hinfo)
oPartFeature.name = "KC_HOLE_" & Feat_Index_holes & "|D=" & CStr(act_Hole.HoleDiameter.Expression & "|T=" & Hinfo)
Call oPartFeature.SetRenderStyle(kOverrideRenderStyle, oRS_Hole)
holethere = True
Debug.Print "HOLE FOUND INDEX = " & Feat_Index_holes
End If
End If
oPartFeature.SetEndOfPart (False)
End If
Next
End Sub