AnsweredAssumed Answered

Basic Macro User Form Question

Question asked by Karl Hosking on Jul 13, 2007
Latest reply on Jul 15, 2007 by Karl Hosking
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.


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


End Sub

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!

Hopefully someone will be able to help me!