How deep is a hole or thread ?

How deep is a hole or thread ?

frank_schalla
Advocate Advocate
443 Views
3 Replies
Message 1 of 4

How deep is a hole or thread ?

frank_schalla
Advocate
Advocate

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

0 Likes
444 Views
3 Replies
Replies (3)
Message 2 of 4

HideoYamada
Advisor
Advisor

Hello,

 

HoleFeature.Depth will return the depth.

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 3 of 4

frank_schalla
Advocate
Advocate

Hello Hideo Yamada

 

Thank's i know it but if the user takes the options through all or to face thso prop is empty !!!

Any ideas ??

 

0 Likes
Message 4 of 4

HideoYamada
Advisor
Advisor

Hello frank,

 


@frank_schalla wrote:

Thank's i know it but if the user takes the options through all or to face thso prop is empty !!!

Really? I got the depth with this code even if the holes are through all.

Sub test()
    Dim pDoc As PartDocument
    Set pDoc = ThisApplication.ActiveDocument
    Dim pCompDef As PartComponentDefinition
    Set pCompDef = pDoc.ComponentDefinition
    
    Dim hf As HoleFeature
    For Each hf In pCompDef.Features.HoleFeatures
        Debug.Print hf.Name & " : " & hf.Depth
    Next hf
End Sub

The result of your model is here :

KC_THREAD|M8|T=15 mm|D=6,75mm|T= : 3.00000000000011
KC_HOLE_1|D=50 mm|T=(O50 mm Durch alle Tiefe) : 3.00000000000009

What version of Inventor are you using?

I'm using Inventor 2020 English + Japanese Language Pack.

 

=====

Freeradical

 Hideo Yamada

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes