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

Hi Georg,

 

In Inventor 2017, there is an api to create a pattern from a sketch.

 

Once you have your points moved to the sketch, you could use the sketch and the hole feature that needs to be patterned, to create a sketch based pattern.

 

In this case your code would be something similar to the following.

 

 

 Sub addHole()


    Dim oDoc As PartDocument
    Set oDoc = ThisDocument
    Dim oCD As PartComponentDefinition
    Set oCD = oDoc.ComponentDefinition
   
    Dim oHF As HoleFeature
    Set oHF = oCD.Features.HoleFeatures.Item(1)
   
    Dim oSK As PlanarSketch
    Set oSK = oHF.Sketch
    Call oSK.Edit
    Dim oPt As Inventor.Point2d
    Set oPt = ThisApplication.TransientGeometry.CreatePoint2d(3 ,1 ) 
    Call oSK.SketchPoints.Add(oPt, True)
    Call oSK.ExitEdit
   
    Dim oNewObjColl As ObjectCollection
    Set oNewObjColl = ThisApplication.TransientObjects.CreateObjectCollection
 
    Call oNewObjColl.Add(oSK.SketchPoints(1)) ' Existing hole centre
    Call oNewObjColl.Add(oSK.SketchPoints(2)) ' New hole centre
    oHF.HoleCenterPoints = oNewObjColl
   

    '## Add  the hole feature to an object collection
    Dim oNewHolesColl As ObjectCollection
    Set oNewHolesColl = ThisApplication.TransientObjects.CreateObjectCollection
    Call oNewHolesColl.Add(oHF)
   

  '## Pass the sketch and hole feature as input to create a  pattern. 
    Dim defn As SketchDrivenPatternDefinition
    Call oCD.Features.SketchDrivenPatternFeatures.Add(oCD.Features.SketchDrivenPatternFeatures.CreateDefinition(oNewHolesColl, oSK))

 

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network