Files
Delete and re-add revision table
Code
'Deletes current revision table and adds a new one, with text in certain cells modified
'Preconditions: Table template path is specified in TABLE_TEMPLATE constant; drawing with _
a revision table is open
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Const TABLE_TEMPLATE = "C:\Program Files\SolidWorks 2013\SolidWorks\lang\english\standard revision block.sldrevtbt"
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim vViews As Variant
Dim swView As SldWorks.View
Dim swTableAnn As SldWorks.TableAnnotation
Dim swAnn As SldWorks.Annotation
Dim swRevTableAnn As SldWorks.RevisionTableAnnotation
Dim i As Integer
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
'Delete existing revision table
Set swView = swDraw.GetFirstView
Do While Not swView Is Nothing
Set swTableAnn = swView.GetFirstTableAnnotation
While Not swTableAnn Is Nothing
If swTableAnn.Type = swTableAnnotation_RevisionBlock Then
Set swAnn = swTableAnn.GetAnnotation
swAnn.Select3 False, Nothing
swModel.Extension.DeleteSelection2 Empty
Exit Do
End If
Set swTableAnn = swTableAnn.GetNext
Wend
Set swView = swView.GetNextView
Loop
'Add new revision table
Set swRevTableAnn = swSheet.InsertRevisionTable(True, Empty, Empty, _
swBOMConfigurationAnchor_TopRight, TABLE_TEMPLATE)
If swRevTableAnn Is Nothing Then
swApp.SendMsgToUser "Insert revision table failed."
Else
Set swTableAnn = swRevTableAnn
swRevTableAnn.AddRevision "A"
swTableAnn.Text(2, 2) = "Keith"
swTableAnn.Text(2, 3) = DateValue(Now)
swTableAnn.Text(2, 1) = "INITIAL RELEASE"
End If
End Sub