Hey All,

Quick question,

What's the best way to control angles using a Macro user form?

I've finally got some time to play with Macro's in Solidworks and I just need a little help with understanding what I'm actually doing. As far as I can tell, angles are translated to radians back and forth, but this leaves me with very inaccurate final angles etc. I've attached a very simple part & macro in a ZIP file to show you exactly what I'm trying to do.

Hopefully someone will be able to help me!

Cheers,

Karl

Quick question,

What's the best way to control angles using a Macro user form?

I've finally got some time to play with Macro's in Solidworks and I just need a little help with understanding what I'm actually doing. As far as I can tell, angles are translated to radians back and forth, but this leaves me with very inaccurate final angles etc. I've attached a very simple part & macro in a ZIP file to show you exactly what I'm trying to do.

Obviously, if I type in 100 in the Angle textbox3, I'd like model to then update to 100 degrees. But because VB or Solidworks converts to radians, I get an odd Angle number. As is, angle part of the macro is incomplete as I'm not too sure of the best way to tackle this problem. Note, that I may be going about the entire project completely wrong too, as I'm self taught with Solidworks and Visual Basic!

Private Sub CommandButton1_Click()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

Set SelMgr = Part.SelectionManager

Part.Parameter("Length1@Sketch1").SystemValue = (TextBox1.Value / 1000)

Part.Parameter("Length2@Sketch1").SystemValue = (TextBox2.Value / 1000)

Part.Parameter("Angle@Sketch1").SystemValue = TextBox3.Value

Part.ForceRebuild

End Sub

Hopefully someone will be able to help me!

Cheers,

Karl

PI = 3.14159265358979323846264338327950288419716939937510

Dim MyVal as double

MyVal = ( (TextBox3.Value * 3.14159265358979323846264338327950288419716939937510) / 180)

you can use Round function.

Round(MyVal, 0)