-
Notifications
You must be signed in to change notification settings - Fork 0
/
creating_fillet.swb
72 lines (53 loc) · 2.51 KB
/
creating_fillet.swb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModeldocext As SldWorks.ModelDocExtension
Dim swSketchMgr As SldWorks.SketchManager
Dim swSelMgr As SldWorks.SelectionMgr
Dim swSketch As SldWorks.Sketch
Dim swVklines As Variant
Dim swFeat As SldWorks.Feature
Dim swSketchPoint As SldWorks.SketchPoint
Dim sketchPointArray As Variant
Dim i As Long
Dim xValue As Double
Dim yValue As Double
Sub main()
Set swApp = CreateObject("SldWorks.Application")
' Create a string type variable for storing default part location
Dim defaultTemplate As String
' Set the value of this string type variable to "Default part template"
defaultTemplate = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swDefaultTemplatePart)
' Create a new part document using the default template
Set swModel = swApp.NewDocument(defaultTemplate, 0, 0, 0)
' Get the model document extension object
Set swModeldocext = swModel.Extension
' Select the top plane using model document extension
swModeldocext.SelectByID2 "Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, swSelectOption_e.swSelectOptionDefault
' Get the sketch manager to create sketch routines
Set swSketchMgr = swModel.SketchManager
' Start a new sketch
swSketchMgr.InsertSketch True
swVklines = swSketchMgr.CreateCornerRectangle(0, 0, 0, 0.2, 0.4, 0)
'Select the active sketch
Set swSketch = swSketchMgr.ActiveSketch
'Create the fillet of 0.01 m radius
'Not sure how this is working as we need to select corners first in solidworks to create fillet at that point
swSketchMgr.CreateFillet 0.01, swConstrainedCornerAction_e.swConstrainedCornerDeleteGeometry
'sketchPointArray = swSketch.GetSketchPoints2
'Obtain corners to fillet
' For i = 0 To UBound(sketchPointArray)
' ' Get value returned by ISketchPoint::GetCoords
' Set swSketchPoint = sketchPointArray(i)
' Debug.Print "Value returned by ISketchPoint::GetCoords: " & swSketchPoint.GetCoords
' ' Get the x & y coordinates
' xValue = sketchPointArray(i).X
' yValue = sketchPointArray(i).Y
' swSketchMgr.CreateFillet 0.01, swConstrainedCornerAction_e.swConstrainedCornerDeleteGeometry
' Debug.Print "Sketch point coordinates: "
' Debug.Print " x: " & xValue
' Debug.Print " y: " & yValue
' Debug.Print " "
' ' Do something useful with the data
' Next i
End Sub