Hi @nsatheesan34D64,
Give this a shot. The circular feature is bugged in Inventor 2020, so I developed and tested this in Inventor 2022.
I've placed a screencast here to show you how the script works.
'Check that script is being run in a part document
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MessageBox.Show("Please re-run this script in a part document.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
End If
'Set the part document variables
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
'Prompt user to select cylinderical face
Dim oCylinderFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceCylindricalFilter, "Select cylinder face")
'Prompt user to select the starting point
Dim StartingPoint As SketchPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchPointFilter, "Select starting point")
Dim StartingPointSketch As PlanarSketch = StartingPoint.Parent
Dim oRefPlane As WorkPlane = StartingPointSketch.PlanarEntity
StartingPointOffset = ThisApplication.MeasureTools.GetMinimumDistance(StartingPointSketch.OriginPointGeometry, StartingPoint.Geometry3d)
'MessageBox.Show(StartingPointOffset)
'Get the cylinder mathematical object
Dim oCylinder As Cylinder = oCylinderFace.Geometry
'Get the cylinder radius
Dim oCylinderRadius As Double = oCylinder.Radius
'Generate the cylinder line
Dim oCylinderAxis As WorkAxis = oCompDef.WorkAxes.AddByRevolvedFace(oCylinderFace)
Try
oCompDef.WorkAxes.Item("CylinderAxis").Delete(False)
Catch
End Try
oCylinderAxis.Name = "CylinderAxis"
oCylinderAxis.Visible = False
'Get user input
Dim HoleDiameter As Double = InputBox("Enter hole diameters", "Enter hole diameters as a decimal", 1)
Dim HoleDepth As Double = InputBox("Enter hole depth as a decimal. If you want it to go all the way througm enter a value way larger than the cylinder diameter", "Enter hole depth", 1)
Dim NumOfHoles As Integer = InputBox("Enter the number of rows", "Enter the number of rows as a whole number", 4)
Dim AngleBetweenHoles As Double = InputBox("Enter angle offset between rows", "Enter angle offset between rows", 4.7)
Dim HeightDifference As Double = InputBox("Enter height difference between rows", "Enter height difference between rows in decimals", 1)
Dim HolesPerRow As Integer = InputBox("Enter the number of holes for each row", "Enter the number of holes for each row as a whole number", 40)
'Arraylist to hold the workplanes
Dim HoleWorkPlanes As New ArrayList
'Set the initial plane to work off of
Try
Dim InitialPlane As WorkPlane = oCompDef.WorkPlanes.AddByPlaneAndTangent(oRefPlane, oCylinderFace, oCompDef.WorkPoints(1).Point)
HoleWorkPlanes.Add(InitialPlane)
Try
oCompDef.WorkPlanes.Item("InitialPlane").Delete(False)
Catch
End Try
InitialPlane.Name = "InitialPlane"
InitialPlane.Visible = False
Catch
MessageBox.Show("Please re-run this script and select a plane that can be tangent to the cylinder face.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
Exit Sub
End Try
For i = 0 To NumOfHoles - 1
Dim HoleCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
'Generate the planes to hold the sketches
Dim wPlaneAngleInRads As Double = AngleBetweenHoles * PI / 180
Dim TempPlane As WorkPlane = oCompDef.WorkPlanes.AddByLinePlaneAndAngle(oCylinderAxis, HoleWorkPlanes(i), wPlaneAngleInRads, True)
Dim HolePlane As WorkPlane = oCompDef.WorkPlanes.AddByPlaneAndOffset(TempPlane, oCylinderRadius)
HolePlane.Visible = False
HolePlane.Name = "HolePlane" & Str(i + 1)
HoleWorkPlanes.Add(HolePlane)
'Draw the sketches with circles
Dim HoleSketch As PlanarSketch = oCompDef.Sketches.Add(HolePlane)
Dim Hole2DCenter As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(i * HeightDifference + StartingPointOffset,0)
HoleSketch.SketchCircles.AddByCenterRadius(Hole2DCenter,HoleDiameter/2)
HoleSketch.Name = "HoleSketch" & Str(i + 1)
'Extrude the holes
Dim oProfile As Profile = HoleSketch.Profiles.AddForSolid
Dim HoleCut As ExtrudeDefinition = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kCutOperation)
HoleCut.SetDistanceExtent(HoleDepth, kNegativeExtentDirection)
Dim Hole As ExtrudeFeature = oCompDef.Features.ExtrudeFeatures.Add(HoleCut)
Hole.Name = "Hole " & Str(i + 1)
HoleCol.Add(Hole)
'Make circular pattern on each row
Dim HolesPerRowDef As CircularPatternFeatureDefinition = oCompDef.Features.CircularPatternFeatures.CreateDefinition(HoleCol,oCylinderAxis,True,HolesPerRow,"360 deg",True)
Dim HolesCircularPattern As CircularPatternFeature = oCompDef.Features.CircularPatternFeatures.AddByDefinition(HolesPerRowDef)
HolesCircularPattern.Name = "HolePattern" & Str(i + 1)
HoleCol.Clear
Next