I am not very fluent in VB, I have the following macro for drawing points in the cam program I use to program wire EDMs
My problem seems to lie in the sine calculations, It is returning negative values, for example, .0372 * sin(30) should be .0186, my equation is returning something like -.036755
Any ideas why this would be?
Thank You
Mike
Code:
Sub cdb()
'Macro Recorder 8/31/2007 by Mike
On Error Resume Next
'Declare the variables
Dim App As Esprit.Application
Dim doc As Esprit.Document
Dim M_Point As Esprit.Point
Dim M_Segment As Esprit.Segment
Dim S, W, L, XSINE, YSINE, X1, Y1, X2, Y2, X3, Y3, S1X, S1Y, S2X, S2Y
'Initialize the App and Doc Variables
Set App = Application
Set doc = App.Document
S = InputBox(prompt, "S Dim", "Input S Dimension")
W = InputBox(prompt, "W Dim", "Input W Dimension")
L = InputBox(prompt, "L Dim", "Input L Dimension")
X1 = 0.0569
Y1 = 0.6874
X2 = 0.273406
Y2 = 0.8124
X3 = 0.150719
Y3 = 1.0249
XSINE = Sin(30) * S
YSINE = Sin(60) * S
S1X1 = X1 + XSINE
S1Y1 = Y1 - YSINE
S2X1 = X2 + XSINE
S2Y1 = Y2 - YSINE
'Add a Point
Set M_Point = doc.Points.Add(S1X1, S1Y1, 0)
'Set the properties for the new Point object
With M_Point
.Color = 65408
.LineType = espSolid
.Grouped = 0 'False
.LineWeight = espLineWeightThin
.X = S1X1
.Y = S1Y1
.Z = 0
.Layer = doc.Layers("STRAIGHT")
End With
'Add a Point
Set M_Point = doc.Points.Add(S2X1, S2X1, 0)
'Set the properties for the new Point object
With M_Point
.Color = 65408
.LineType = espSolid
.Grouped = 0 'False
.LineWeight = espLineWeightThin
.X = S2X1
.Y = S2Y1
.Z = 0
.Layer = doc.Layers("STRAIGHT")
End With
'Very Important - destroy all of the Objects
Set M_Point = Nothing
Set M_Segment = Nothing
Set doc = Nothing
Set App = Nothing
Set S = Nothing
Set W = Nothing
Set L = Nothing
Set X1 = Nothing
Set Y1 = Nothing
Set X2 = Nothing
Set Y2 = Nothing
Set X3 = Nothing
Set Y3 = Nothing
Set S1X = Nothing
Set S1Y = Nothing
Set S2X = Nothing
Set S2Y = Nothing
End Sub
My problem seems to lie in the sine calculations, It is returning negative values, for example, .0372 * sin(30) should be .0186, my equation is returning something like -.036755
Any ideas why this would be?
Thank You
Mike