OK,
So I thought I could start my macro creator career by doing the simple "start recorder", hit Tools, select equations, create equations, stop recorder and save equation.
Simple right? No such luck. For some reason I got the headers and some other info but no equations. So to see if I was really getting anything I started the recorder, rotated the model and then attempted to create the equations. Now it will rotate the model but still doesn't create any equations. Below I have cleaned out the majority of the rotate but left 4 highlighted lines to show where that was. I now see reference to equations but only get 0s and nothings. Do I replace the string of : "EGNFOLDER", 0, 0, 0, false,0, Nothing, 0) with my desired equations? or where do I place them?
The equations I am looking to add are:
"weight"= round ("SW-Mass",2)
"Paint Volume"= round ("SW-SurfaceArea"*.009/231,2)
and "Thinner Volume"= "Paint Volume"/2
Then I would like to add a text box indicating the information has been added, something like:
MsgBox "weight is: " & Weight & vbNewLine & "Paint Volume is: " & Paint Volume & vbNewLine & "Thinner Volume is: " & Thinner Volume
Could someone help me to understand why I can't add the equations by recording? And then let me know where and how to place my lines in the code? My goal is to create a macro to create and enter the equations in existing models so I can then enter the custom properties with the Property Tab Builder. Well that and learn how to create macros.
Thank you
' ******************************************************************************
' C:\\Users\\jhs\\AppData\\Local\\Temp\\swx5656\\Macro1.swb - macro recorded on 03/13/17 by jhs
' ******************************************************************************
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.RotateAboutCenter 2.51595781120379E-03, 0.005088972980977
Set myModelView = Part.ActiveView
myModelView.RotateAboutCenter 2.51595781120379E-03, 0
' Roll View
Dim swModelView As Object
Set swModelView = Part.ActiveView
swModelView.RollBy 0
boolstatus = Part.Extension.SelectByRay(0.138294868704691, 4.94453083906876E-02, -0.488170518034337, 0.762876300885792, -0.336397784504752, -0.552137917668317, 5.21914013583155E-03, 2, False, 0, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Equations", "EQNFOLDER", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Equations", "EQNFOLDER", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
End Sub
SolidworksApi macros