Hi All,
I am new to macros and am looking for a little help getting a macro to work the way I want it to. I am using an input box for the user to input the sketch number that contains a named dimension I want to use in the equation. I am able to get all of the variables to show up the way I want in the code but do not know how to get them to write into the equation list in my part when I am using the variables. If I hard code the sketch names they write into the equation list fine. I am thinking I do not have the variables called out properly...
Thanks, Mike
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Equations", "EQNFOLDER", 0, 0, 0, False, 0, Nothing, 0)
Dim nmbText As String
nmbText = InputBox("Specify The Sketch Number") 'user enters sketch number with the named dimensions in it
Dim nmb As Integer
Dim wnText As String
Dim lnText As String
Dim WText As String
Dim LText As String
nmb = CInt(nmbText) 'this is the sketch number
wn = "W@Sketch" & nmb 'full width sketch name
ln = "L@Sketch" & nmb 'full length sketch name
Dim swEquationMgr As Object
Set swEquationMgr = Part.GetEquationMgr()
'the following worked as long as my sketch is named Sketch1 frequently this is something other than Sketch1
'swEquationMgr.Add -1, """SquareFeet""= ""W@Sketch1"" * ""L@Sketch1"" / 144"
'the follwing does not work attempting to use variables to make the equation
swEquationMgr.Add -1, """SquareFeet""= wn * nmb / 144"
boolstatus = Part.ForceRebuild()
Part.Save
End Sub