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

No problem. Try how does this work for you. If it works you should have a sketch point created and the punch tool dialog should pop up.

 

Public Sub NewSketchOnPlane()


Dim partDoc As PartDocument
Set partDoc = ThisApplication.ActiveDocument

 

' Create a new sketch on a selected face.
Dim planarEntity As Object
Set planarEntity = ThisApplication.CommandManager.Pick(kAllPlanarEntities, _
"Select a face or work plane.")
Dim sk As Sketch
Set sk = partDoc.ComponentDefinition.Sketches.Add(planarEntity)

 

' Bring the sketch into edit mode.
sk.Edit

 

'Add a sketch point to a planar sketch
Dim oPointOnFace As Point
Set oPointOnFace = planarEntity.PointOnFace 'just use the PointOnFace as an example, sounds you will get user input anyway
sk.SketchPoints.Add sk.ModelToSketchSpace(oPointOnFace)

 

'Exit sketch edit
sk.ExitEdit

 

' Find the ButtonDefinition of Punch Tool command and execute it
Dim oDef As ButtonDefinition
Set oDef = ThisApplication.CommandManager.ControlDefinitions("SheetMetalPunchToolCmd")

 

'Execute the Punch Tool command
oDef.Execute

 

End Sub