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?
--------------------------------------------------------
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
Solved! Go to Solution.
Solved by WCrihfield. Go to 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
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.