Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
sajith_subramanian
in reply to: GeorgK

Hello Georg,

 

To get all the hole points from same type of holes to one sketch, you could try the following code which gets the hole centre points and adds them to a new sketch.

 

  Dim xcoord As Double
  Dim ycoord As Double
  Dim oPt As Inventor.Point2d
 

 ' Create a new sketch on the XY plane.
   Dim oNewSketch As PlanarSketch
   Set oNewSketch = oCD.Sketches.Add(oCD.WorkPlanes.Item(3))

 

' Put the sketch in edit mode.
    oNewSketch.Edit


For Each oHoleFeat In oDoc.ComponentDefinition.Features.HoleFeatures
 If oHoleFeat.HoleType = HoleTypeEnum.kDrilledHole Then
     
    xcoord = oHoleFeat.HoleCenterPoints.Item(1).Geometry.X
    ycoord = oHoleFeat.HoleCenterPoints.Item(1).Geometry.Y
    Set oPt = ThisApplication.TransientGeometry.CreatePoint2d(xcoord, ycoord)
    Call oNewSketch.SketchPoints.Add(oPt, True)


 End If   


Next


oNewSketch.ExitEdit

 


Sajith Subramanian
Autodesk Developer Network