Code behaves as drills at center of the sheet metal
I want Drill on the side of cabinate at door.
Dim oSheetMetalDoc As PartDocument
oSheetMetalDoc = ThisApplication.ActiveEditDocument
' a reference to the component definition.
Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oSheetMetalDoc.ComponentDefinition
' a reference to the sheet metal features collection.
Dim oSheetMetalFeatures As SheetMetalFeatures
oSheetMetalFeatures = oCompDef.Features
Dim oFace As Face
'Keep Selecting Faces, Hit Esc to finish
Do
oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Select a face")
If Not oFace Is Nothing Then
Exit Do
End If
Loop While Not oFace Is Nothing
' Get the outer loop of the face.
Dim outerLoop As EdgeLoop
For Each outerLoop In oFace.EdgeLoops
If outerLoop.IsOuterEdgeLoop Then
Exit For
End If
Next
' Create a workpoint at the edge mid-point
Dim oWorkPoint As WorkPoint
oWorkPoint = oCompDef.WorkPoints.AddAtCentroid(outerLoop)
Dim oPointPlacement As PointHolePlacementDefinition
oPointPlacement = oCompDef.Features.HoleFeatures.CreatePointPlacementDefinition(oWorkPoint,oFace)
' Create the hole feature, 0.5 cm dia
Call oCompDef.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
oPointPlacement, 0.5, kPositiveExtentDirection)
'turn off workpoint
oWorkPoint.Visible = False