Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can not make hole M4x1 via sketch

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
hieut1392
239 Views, 2 Replies

Can not make hole M4x1 via sketch

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

 

 

 

 

 

 

2 REPLIES 2
Message 2 of 3
WCrihfield
in reply to: hieut1392

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)

Message 3 of 3
hieut1392
in reply to: WCrihfield

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

hieut1392_0-1676518936269.png

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report