PDA

View Full Version : Trig functions



Barry Clark
24th Mar 2005, 09:07 pm
I am starting to use trig functions in my routines and I have hit a bump.

Any help in what I am doing will be greatly appeciated.

Where I think my problem is occurs at converting the input to usable data for the math. I just wasn't able to find where I could get the Dim argument and the Set argument to agree.


Sub PCoords()
Dim A As String, D As String
Dim X As String, Y As String
A = ThisDrawing.Utility.GetString(False, "Enter angle (degrees): ")
D = ThisDrawing.Utility.GetString(False, "Enter distance : ")
A = A * (pi / 180)
X = D * Cos(A)
Y = D * Sin(A)
MsgBox X & ", " & Y
End Sub

I couldn't find anything about this through the search function.

Any help would be greatly appreciated. Thanks!

devitg
14th Apr 2005, 04:04 pm
I do not know nothing about the VBA

Could you handle string as values in a formula????
Maybe yiou have to change from string to numbers :oops:

hendie
15th Apr 2005, 08:23 am
step through your code and watch the value of A

where have you declared pi ?



Sub PCoords()
Dim A As Double, D As Double
Dim X As Double, Y As Double
Dim Pi
Pi = 4 * Atn(1)

A = ThisDrawing.Utility.GetAngle(, "Enter angle (degrees): ")
D = ThisDrawing.Utility.GetDistance(, "Enter distance : ")
A = A * (Pi / 180)
X = D * Cos(A)
Y = D * Sin(A)

MsgBox "X= " & X & ", " & "Y= " & Y
End Sub

devitg
15th Apr 2005, 11:37 am
Hendie, you changed the variable to DOUBLE , as I supposed it should be.
I miss about the PI , the first error did not allow me to see the other.

As I told before, I do not know nothing about VBA, could you route me or explain how it is used in acad???? :roll:

hendie
15th Apr 2005, 11:53 am
... could you route me or explain how it is used in acad????

I'm not sure I understand what you mean ~ can you try and exaplain a bit more please ?

if you mean how can it be applied in Autocad, take a look at a couple of my programs on http://www.resourcecad.com/ ~ the Block Isolation utility and the Cone Development Tool are both written in VBA