Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.