AnsweredAssumed Answered

Cut Extrude Form Issue

Question asked by Sam Pike on May 15, 2018
Latest reply on May 16, 2018 by Nilesh Patel

I am having a problem with a portion of my program that uses a Form for the user to input a distance for the Cut-Extrude.

The 1st part of the program has a couple of parts in an assembly. One of the parts has a sketch. The sketch is then being used as a converted entity on the other part and cut. I would like the user to input a distance for the cut-extrude.

Currently it is going through, selecting the sketch, starting a new sketch on the part, and brings up the dialog box. I can input a number but it does nothing from there.

In the UserForm1, I have the text box called DepthTextBox and the command button as CommandButton1


Please help


Dim swApp As Object
Dim swComp As SldWorks.Component2
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swComp = swSelMgr.GetSelectedObjectsComponent3(1, 0)

boolstatus = Part.Extension.SelectByRay(-0.115676192932654, 6.34999999999764E-03, 1.29860726030984E-03, -0.108448573022486, -0.54545076872453, -0.831097085728981, 1.58123104284041E-03, 2, False, 0, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByRay(-0.106978428172582, 6.34999999999764E-03, 1.76640949543412E-02, -0.108448573022486, -0.54545076872453, -0.831097085728981, 1.58123104284041E-03, 2, False, 0, 0)
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("Locating Sketch@" + swComp.Name2 + "@" + swModel.GetTitle, "SKETCH", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = Part.SketchManager.SketchUseEdge3(False, False)
Part.SketchManager.InsertSketch True
Dim myFeature As Object

'Show user Form

End Sub
Public Sub CreateDepth(InputDepth As Double)

Dim DepthDistance As Double

DepthDistance = InputDepth

Set myFeature = swModel.FeatureManager.FeatureCut4(True, False, False, 0, 0, InputDepth, InputDepth, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, False, True, True, True, True, False, 0, 0, False, False)
Part.SelectionManager.EnableContourSelection = False
Part.ClearSelection2 True
End Sub




Private Sub CommandButton1_Click()

Dim Depth As Double

InputDepth = DepthTextBox.Text
Call CreateDepth(InputDepth)
End Sub