LFowler
Mechanical
- Feb 7, 2012
- 7
I'm sure this problem has a simple solution, I just don't write code, hence:
The code below *works* but I am looking for something a bit more elegant. Basically the macro runs through the custom properties to see what revision the drawing is on. The property that decides the revision is named "REVISION A" or B, or C, etc. and the value is "AA", "AB", etc. (no quotes for any).
I want the macro to output a string that represents the most recent revision, for example "-AF".
How would you make this code simpler?
The code below *works* but I am looking for something a bit more elegant. Basically the macro runs through the custom properties to see what revision the drawing is on. The property that decides the revision is named "REVISION A" or B, or C, etc. and the value is "AA", "AB", etc. (no quotes for any).
I want the macro to output a string that represents the most recent revision, for example "-AF".
How would you make this code simpler?
Code:
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim ext As String
Dim revA As String
Dim revB As String
Dim revC As String
Dim revD As String
Dim revE As String
Dim revF As String
Dim revG As String
Dim revH As String
Dim revI As String
Dim revJ As String
Dim revK As String
Dim revL As String
Dim revM As String
Dim revN As String
Dim revO As String
Dim revP As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Grabs potential revision level
revA = swModel.GetCustomInfoValue("", "REVISION A")
revB = swModel.GetCustomInfoValue("", "REVISION B")
revC = swModel.GetCustomInfoValue("", "REVISION C")
revD = swModel.GetCustomInfoValue("", "REVISION D")
revE = swModel.GetCustomInfoValue("", "REVISION E")
revF = swModel.GetCustomInfoValue("", "REVISION F")
revG = swModel.GetCustomInfoValue("", "REVISION G")
revH = swModel.GetCustomInfoValue("", "REVISION H")
revI = swModel.GetCustomInfoValue("", "REVISION I")
revJ = swModel.GetCustomInfoValue("", "REVISION J")
revK = swModel.GetCustomInfoValue("", "REVISION K")
revL = swModel.GetCustomInfoValue("", "REVISION L")
revM = swModel.GetCustomInfoValue("", "REVISION M")
revN = swModel.GetCustomInfoValue("", "REVISION N")
revO = swModel.GetCustomInfoValue("", "REVISION O")
revP = swModel.GetCustomInfoValue("", "REVISION P")
If revP = "AP" Then
ext = "-AP"
ElseIf revO = "AO" Then
ext = "-AO"
ElseIf revN = "AN" Then
ext = "-AN"
ElseIf revM = "AM" Then
ext = "-AM"
ElseIf revL = "AL" Then
ext = "-AL"
ElseIf revK = "AK" Then
ext = "-AK"
ElseIf revJ = "AJ" Then
ext = "-AJ"
ElseIf revI = "AI" Then
ext = "-AI"
ElseIf revH = "AH" Then
ext = "-AH"
ElseIf revG = "AG" Then
ext = "-AG"
ElseIf revF = "AF" Then
ext = "-AF"
ElseIf revE = "AE" Then
ext = "-AE"
ElseIf revD = "AD" Then
ext = "-AD"
ElseIf revC = "AC" Then
ext = "-AC"
ElseIf revB = "AB" Then
ext = "-AB"
ElseIf revA = "AA" Then
ext = "-AA"
End If
End Sub