Hi,
Thank you!
Instead of picking a face, I'm using the following code to avoid user-interaction:
oEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
Dim oFace As Face
oFace = oEntities.FindEntity("Face0")
Dim sketch As Inventor.PlanarSketch
sketch = oAssDef.Sketches.Add(oFace)
The code runs fine up until the point where the punchtool gets inserted. So the sketch gets created, points in the sketch are inserted etc.. But when it comes down to inserting the punchtool it gives me an error.

So if i uncomment:
features.PunchToolFeatures.Add(points, featureDef, rad)
Then it works fine. I can use the created sketch with points and manually insert the punch tool with no problems.
Could you please show me where i made a mistake?
Here's the code in its entirety:
oAssDoc = ThisApplication.ActiveDocument
oAssDef = oAssDoc.ComponentDefinition
invApp = ThisApplication
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
'CREATE SKETCH
oEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
Dim oFace As Face
oFace = oEntities.FindEntity("Face0")
Dim sketch As Inventor.PlanarSketch
sketch = oAssDef.Sketches.Add(oFace)
sketch.Name = "PunchTool Sketch"
'DRAW POINT ON SKETCH
Dim tg As Inventor.TransientGeometry = invApp.TransientGeometry
Dim points As Inventor.SketchPoints = sketch.SketchPoints
Dim x As Double
x = 2.0
Dim y As Double
z = 2.0
Row1Start = points.Add(tg.CreatePoint2d(x, z), True)
'CHOOSE PUNCH TOOL
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
Dim oPartDef As PartComponentDefinition
oPartDef = oPartDoc.ComponentDefinition
Dim oFeatures As PartFeatures
oFeatures = oPartDef.Features
Dim oiFeatureDef As iFeatureDefinition
Dim def As SheetMetalComponentDefinition = sketch.Parent
Dim features As SheetMetalFeatures = def.Features
Dim featureDef = features.PunchToolFeatures.CreateiFeatureDefinition("C:\Users\Public\Documents\Autodesk\Inventor 2022\Catalog\Punches\keyhole.ide")
Dim degrees As Double = 45
Dim rad As Double = degrees * Math.PI / 180
'features.PunchToolFeatures.Add(points, featureDef, rad)