Can not make hole M4x1 via sketch

Can not make hole M4x1 via sketch

hieut1392
Enthusiast Enthusiast
290 Views
2 Replies
Message 1 of 3

Can not make hole M4x1 via sketch

hieut1392
Enthusiast
Enthusiast

Like title, i am doing a hole punching macro by assigning hole size and profile, however i can't run M4x1, but M4x0.5 does. Can you help me?

--------------------------------------------------------

Screenshot 2023-02-16 011752.png

 

 

 

 

Sub MakeDrillHoleTestMAIN()
Call MakeDrillHoleTest("sketchHole2", "GB Metric profile", "M4x1")
End Sub
'--------------------------------------------------------------------'
Sub MakeDrillHoleTest(sketchName As String, profile As String, holeType As String)

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveEditDocument

Dim oCompDef As PartComponentDefinition
Set oCompDef = oDoc.ComponentDefinition

Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry

Dim oSketches As PlanarSketches
Set oSketches = oCompDef.Sketches

Dim oSketch As PlanarSketch
Set oSketch = oSketches.Item(sketchName)

If oSketch.Type = kPlanarSketchProxyObject Then
Set oSketch = oSketch.NativeObject
End If

Dim oHoleCenters As ObjectCollection
Set oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection

Dim oSP As Integer

For oSP = 1 To oSketch.SketchPoints.Count
    If oSketch.SketchPoints.Item(oSP).HoleCenter Then
        Call oHoleCenters.Add(oSketch.SketchPoints.Item(oSP))
    End If
Next

Dim oLinearPlacementDef As SketchHolePlacementDefinition
Set oLinearPlacementDef = oCompDef.Features.HoleFeatures.CreateSketchPlacementDefinition(oHoleCenters)

Dim oDimThread As HoleTapInfo
Set oDimThread = oCompDef.Features.HoleFeatures.CreateTapInfo(True, profile, holeType, "6H", True)

Call oCompDef.Features.HoleFeatures.AddDrilledByThroughAllExtent(oLinearPlacementDef, oDimThread, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)

oDoc.Rebuild

End Sub

 

 

 

 

 

 

0 Likes
Accepted solutions (1)
291 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @hieut1392.  I do not see the value "M4x1" as an available option within the 'stock' "thread.xls" file that it references in my 2022.4 installation.  That is likely why it is failing.  You may be able to add that line item into the Excel file, if needed, but I would keep a copy of the original available, as a backup.  That thread.xls file is installed with Inventor to the following location, by default:

C:\Users\Public\Documents\Autodesk\Inventor 2022\Design Data\XLS\en-US\thread.xls

But the whole Design Data folder can be moved, as long as you update the Project file, and the File tab setting within the Application Options.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

hieut1392
Enthusiast
Enthusiast

i understood. M6 is M6x1, but M4 is M4x0.7 :D, thank you.

hieut1392_0-1676518936269.png

 

0 Likes