Hello and thank You for Your time.
For my Batchelor's thesis I am trying to male a robot inspired by the ABENICS Ball Joint. I want to create a monopole gear in Solidworks by continuously pasting a sketch and changing two angles in the sketch.
Whenever I try to fully turn the main - cross spherical gear around the monopole gear at 130 degrees around the monopole gear, while the CS gear is rotated at 65 degrees something weird is happening. From research it seams that Soidworks solver is playing some tricks on me and the result doesn't make any sense, it seems like Soidworks decided to throw the constrains out the window.
Below is a screenshot of the right gear, it's dimensioned weirdly in an attempt to remove ambiguity.
The second screenshot shows what happens at 130 deg and 65deg rotations
Below I attach the code I'm using to create revolved bodies around the main body.
Option Explicit
Private Const PI As Double = 3.14159265358979 Private Const swSubtractOp As Long = 15902
Sub main() Dim swApp As SldWorks.SldWorks Dim Part As SldWorks.ModelDoc2 Dim boolstatus As Boolean Dim selData As SldWorks.SelectData Dim bodies As Variant Dim b As SldWorks.Body2 Dim feat As SldWorks.Feature Dim myDim As SldWorks.Dimension
Dim iter As Long
Dim sketchName As String
Dim dim1Name As String
Dim dim10Name As String
Dim angleRad As Double
' — Connect to SW —
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
If Part Is Nothing Then
MsgBox "Open a part document first.", vbExclamation
Exit Sub
End If
For iter = 0 To 14
' build names
sketchName = "Sketch" & (iter + 2)
dim1Name = "D1@" & sketchName
dim10Name = "D10@" & sketchName
' 1) copy Sketch1 › new sketchN
Part.ClearSelection2 True
Part.Extension.SelectByID2 "Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0
Part.EditCopy
Part.ClearSelection2 True
Part.Extension.SelectByID2 "Right Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0
Part.Paste
Part.ClearSelection2 True
' 2) edit SketchN
Part.Extension.SelectByID2 sketchName, "SKETCH", 0, 0, 0, False, 0, Nothing, 0
Part.EditSketch
Part.ClearSelection2 True
' 3) compute radians from degrees
angleRad = (iter * 10) * PI / 180#
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Point1", "SKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgCOINCIDENT"
' 4) set D1@SketchN
Set myDim = Part.Parameter(dim1Name)
If Not myDim Is Nothing Then myDim.SystemValue = angleRad
' 5) set D10@SketchN
Set myDim = Part.Parameter(dim10Name)
If Not myDim Is Nothing Then myDim.SystemValue = angleRad / 2
Part.ClearSelection2 True
' 6) revolve around Line3 (fixed SelectByID2 call!)
boolstatus = Part.Extension.SelectByID2( _
"Line3", _
"SKETCHSEGMENT", _
0#, _
3.93043218323051E-02, _
5.17907137381132E-04, _
True, _
16, _
Nothing, _
0)
If boolstatus Then
Set feat = Part.FeatureManager.FeatureRevolve2( _
True, True, False, False, False, False, _
0, 0, 2 * PI, 0, _
False, False, 0.01, 0.01, 0, 0, 0, _
False, True, True)
Else
Debug.Print "Could not select Line3 in " & sketchName
End If
Part.ClearSelection2 True
Next iter
MsgBox "All done!", vbInformation
End Sub
