For the clearance hole APIs we expose the HoleFeatures.CreateClearanceInfo and also make the HoleFeature.ClearanceInfo writable in Inventor 2020.1 so users now can create a clearance hole via API.
Here is a sample:
Sub test()
' open a part document with a hole feature
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oHole As HoleFeature
Set oHole = oDoc.ComponentDefinition.Features.HoleFeatures(1)
Debug.Print oHole.IsClearanceHole
' Create a HoleClearanceInfo(not associative with any HoleFeature)
Dim oHCI As HoleClearanceInfo
Set oHCI = oDoc.ComponentDefinition.Features.HoleFeatures.CreateClearanceInfo("Ansi Unified Screw Threads", "Flat Head Machine Screw (100)", "#1", kNormalFitType)
Debug.Print oHCI.FastenerStandard
Debug.Print oHCI.FastenerType
Debug.Print oHCI.FastenerSize
Debug.Print oHCI.FastenerFitType
' we can change the property when the HoleClearanceInfo is not associative with a HoleFeature
oHCI.FastenerStandard = "ISO"
oHCI.FastenerType = "Countersunk Flat Head Screw ISO 2009/7046"
oHCI.FastenerSize = "M1.6"
oHCI.FastenerFitType = kCloseFitType
Debug.Print "----------------------------"
Debug.Print oHCI.FastenerStandard
Debug.Print oHCI.FastenerType
Debug.Print oHCI.FastenerSize
Debug.Print oHCI.FastenerFitType
' set the hole as a clearance hole
oHole.ClearanceInfo = oHCI
Debug.Print oHole.IsClearanceHole
' retrieve the HoleClearanceInfo from a HoleFeature
Set oHCI = oHole.ClearanceInfo
Debug.Print "----------------------------"
Debug.Print oHCI.FastenerStandard
Debug.Print oHCI.FastenerType
Debug.Print oHCI.FastenerSize
Debug.Print oHCI.FastenerFitType
' now the oHCI is associative with a HoleFeature, we don't allow to change a property(like FastenerStandard) directly on the property
' but you can call the SetClearanceInfo method to change the properties, and the change will affect the HoleFeature directly
Call oHCI.SetClearanceInfo("Ansi Unified Screw Threads", "Flat Head Machine Screw (82)", "#8", kNormalFitType)
Debug.Print "----------------------------"
Debug.Print oHCI.FastenerStandard
Debug.Print oHCI.FastenerType
Debug.Print oHCI.FastenerSize
Debug.Print oHCI.FastenerFitType
' also you can create another HoleClearanceInfo(not associative with any HoleFeature), and assign it to the HoleFeature.ClearanceInfo to change its clearance info
Dim onewHCI As HoleClearanceInfo
Set onewHCI = oDoc.ComponentDefinition.Features.HoleFeatures.CreateClearanceInfo("DIN", "Countersunk Flat Head Screw DIN EN ISO 2009", "M1.6", kNormalFitType)
oHole.ClearanceInfo = onewHCI
Set oHCI = oHole.ClearanceInfo
Debug.Print "----------------------------"
Debug.Print oHCI.FastenerStandard
Debug.Print oHCI.FastenerType
Debug.Print oHCI.FastenerSize
Debug.Print oHCI.FastenerFitType
End Sub

Leave a Reply