×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Excell/API/Macro/Conversion

Excell/API/Macro/Conversion

Excell/API/Macro/Conversion

(OP)
I'm writing a macro within Excel.  When I transfer a cell value into a SolidWorks model dimension I divide the cell value by 1000 to get a millimeter value for the model, as in the following example:

Part.Parameter("Dim@Sketch@Model.SLDPRT").SystemValue = [cell].Value / 1000

This works fine for linear dimensions.

Problem: I want to transfer an angular value.  I can't seem to figure out what the relationship is during the transfer.  For instance, when I want to transfer the value of 36°, it transforms into 2063°.

Does anyone have a suggestion for a conversion factor?  It doesn't appear to even be a radian value, ie. 36/360*2pi = .628pi.  The closest that I can get is (36/1000) * (36/2), but this yields 37°+.

I'm totally baffled.

Regards,

Christopher Zona
Litens Automotive Partnership
Concord, Ontario, Canada

RE: Excell/API/Macro/Conversion

Actually it is a Radian value.

1 Radian = 360/2pi = 360/2/pi = 57.29577951°

So your angular cell conversion should be Value/(360/(2pi))

Proof:- 2063/57.29577951 = 36.00614247
Note; the 2063° figure you quote, must have been rounded off.

from (the City of) Barrie, Ontario.

Support bacteria - they're the only culture some people have

RE: Excell/API/Macro/Conversion

(OP)
Great! Worked like a charm.  The question now is how to do I put pi into my code?

I tried using pi() as you would type it into a cell formula but the macro doesn't like that.

For now I am using 3.14159, which close enough.  It returns 35.99996959deg, but I am a bit of a perfectionist and would like to see 36.

Any ideas?

Regards,

Z

RE: Excell/API/Macro/Conversion

(OP)
Sorry to waste your time.  I figured it out.

Const pi As Double = 3.14159265358979

Regards,

Z

RE: Excell/API/Macro/Conversion

Could you put pi() into another cell & reference it to the cell which is used in the macro?

Or use 3.14159265358979..........

from (the City of) Barrie, Ontario.

Support bacteria - they're the only culture some people have

RE: Excell/API/Macro/Conversion

Perhaps you could do the calculating in Excel.  Excel has functions for converting radians to degrees and vice-versa.  Excel also has a function for π.

Maybe it would help to buffer the data transfer.  Pass the Excel cell values to a variable, then pass the variable value to the SolidWorks entity.

Due to illness, the part of The Tick will be played by... The Tick.
http://www.EsoxRepublic.com

RE: Excell/API/Macro/Conversion

Most common VBA 'pi function': 4.0*ATN(1.0)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources