Indeed, I don't see how to add a revision line in Integration either.
On the macro side I have this which does the job, but to be modified according to your own properties. (What a name for the rev and for the description.
Currently for the description there is an input box that posts the question but possibility to put a text in hard quite simply.
Then you just have to launch the macro in Integration and it does the job in batch.
Code:
'This macro automates the adding of revision information to a drawing document
'Precondition: Any open solidworks drawing document
'Postcondition: A revision line added to the revision table and the revision custom _
property of the document and all part/assembly files with the same _
drawing number incremented by one.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDrwDoc As SldWorks.DrawingDoc
Dim swRevTable As SldWorks.RevisionTableAnnotation
Dim swView As SldWorks.View
Dim swRefModel As SldWorks.ModelDoc2
Dim revTableTemp As String
Dim Rev As String
Dim revDesc As String
Dim drwNo As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Verify active document is a drawing
If swModel Is Nothing Then
swApp.SendMsgToUser2 "Please open a .slddrw document and try again!", swMbWarning, swMbOk
End
ElseIf swModel.GetType <> swDocDRAWING Then
swApp.SendMsgToUser2 "This macro only works with .slddrw documents!", swMbWarning, swMbOk
End
End If
Set swDrwDoc = swModel
Set swRevTable = swDrwDoc.GetCurrentSheet.RevisionTable
revTableTemp = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swFileLocationsRevisionTableTemplates)
'Set the revision description for the revision to be added
revDesc = InputBox("Enter revision description:", "Add Revision")
'verify the cancel button was not pressed
If revDesc = "" Then
End
End If
'add revision table if one doesn't exist and set the revision string
If swRevTable Is Nothing Then
Set swRevTable = swDrwDoc.GetCurrentSheet.InsertRevisionTable(True, 0, 0, swBOMConfigurationAnchor_BottomRight, revTableTemp & "\standard revision block.sldrevtbt")
Rev = swModel.CustomInfo("Revision") + 1
ElseIf swRevTable.CurrentRevision = "" Then
Rev = swModel.CustomInfo("Revision") + 1
Else
'Rev = swRevTable.Text(0, 0) + 1
'Rev = A
End If
'add revision & description to the revision table
swRevTable.AddRevision Rev
swRevTable.Text(0, 2) = revDesc
'if new revision is less 10, append 0 to beginning
If Rev < 10 Then Rev = "0" & Rev
'bump the revision of model if part/assembly no. is the same as the drawing no.
drwNo = Left(swModel.GetPathName, Len(swModel.GetPathName) - 7)
drwNo = Replace(drwNo, "C:\PDMWorks Local\", "")
Set swView = swModel.GetFirstView
Set swView = swView.GetNextView
Do
'Debug.Print swView.Name
Set swRefModel = swView.ReferencedDocument
If InStr(1, swRefModel.GetPathName, drwNo) Then swRefModel.CustomInfo("Revision") = Rev
If swRefModel.GetType = swDocASSEMBLY Then
Dim swComps() As SldWorks.Component2
Dim swComp As Variant
Dim swComponent As SldWorks.ModelDoc2
swComps = swRefModel.GetComponents(True)
For Each swComp In swComps
Set swComponent = swComp.GetModelDoc2
If InStr(1, swComp.GetPathName, drwNo) Then swComponent.CustomInfo("Revision") = Rev
Next
End If
Set swView = swView.GetNextView
Loop Until swView Is Nothing
'set Revision custom property of document and reduce the revision table to the last 3 revisions
swModel.CustomInfo("Revision") = Rev
If swRevTable.RowCount > 4 Then
Rev = Rev - 3
Do
swRevTable.DeleteRevision Rev, True
Rev = Rev - 1
Loop Until swRevTable.RowCount = 4
End If
swModel.EditRebuild3
End Sub
To do this type of processing I use "Integration" associated with a small Macro. -> you will have to modify it with: The exact location of your annotaion table: for the order: Set mytablerev = currentsheet. InsertRevisionTable(True, 0, 0, 3, "W:\Modeles_solidworks\table_de_revision\YOUR REVISION TABLE.sldrevtbt")
Optionally the Name of the layer on which you want your Table: myRevisionTable.GetAnnotation.Layer = "Annotation"
And especially the keyword set in your Solidworks settings for new Revision ... (System Option... Drawing... custom property used as a revision... Value = swModel.DeleteCustomInfo("Revision") Value = swModel.AddCustomInfo3("", "Revision", swCustomInfoText, Revis)
Here is the macro in question:
Public swApp As SldWorks.SldWorks
Public swDoc As SldWorks.ModelDoc2
Public SwSheet As SldWorks.DrawingDoc
Public swview As SldWorks.View
Public SwTableRev As TableAnnotation
Public swAnn As SldWorks.Annotation
Public currentsheet As Object
Public mytablerev As Object
Dim LayerMgr As SldWorks.LayerMgr
Dim draw As SldWorks.ModelDoc2
Sub Ajout_table_rev()
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set SwSheet = swDoc
'insertion table
'attention changer le chemin pour la table de revision
' si true alors la table se met sur le point d'ancrage sinon sur coordonné 0,0
Set currentsheet = SwSheet.GetCurrentSheet
Set mytablerev = currentsheet.InsertRevisionTable(True, 0, 0, 3, _
"W:\Modeles_solidworks\table_de_revision\VOTRE TABLE DE REVISION.sldrevtbt") 'A Modifier
Set myRevisionTable = currentsheet.RevisionTable
longstatus = myRevisionTable.AddRevision("")
'Deplace la table sur le calque "Annotation"
myRevisionTable.GetAnnotation.Layer = "Annotation" 'A Modifier si besoin
Dim Revis As String
Revis = myRevisionTable.CurrentRevision
'Ajoute la valeur de "revision" sur la table
Dim Valeur As String
Set swModel = swApp.ActiveDoc
Valeur = swModel.DeleteCustomInfo("Revision") 'A Modifier si besoin
Valeur = swModel.AddCustomInfo3("", "Revision", swCustomInfoText, Revis) 'A Modifier si besoin
'force la reconstruction
Dim bRet As String
bRet = swModel.Rebuild(swRebuildOptions_e.swForceRebuildAll)
End Sub
Then, after setting "Intergration" with the "Texts" information to your liking...., add the operation "Launch a macro"... (Method: Insert_table_revision1. Ajout_table_rev)