Hello, I would like to match the numbering of my revision with the label of revisions.
in the options we have the choice only with 0,1,2,3 or A,B,C.....
Unless I modify it by hand each time I pass a hint, I haven't found a place to change the label automatically. I put an image in PJ to explain my point
For my part, I didn't know that it can be changed, but in any case this label fits in and refers to the last index.
Then, to delete it when passing a higher index, you can delete it by answering that you want to delete the label, otherwise it erases the index of the latest version.
for example if you are in B and you want to go to C, well by removing this label "B" it removes the line in the revision block.
You probably need to modify your template file, the one you start from when creating each plan (Layout template *.drwdot)
To see the location of your file template tools/option/location of files\ templates of memory documents (unless it's in background map - to be checked according to extensions)
And once the initial model file has been modified, all your new MEPs will have the new type of index, but all the previous MEPs will have to be taken back.
For the macro, here are 2 examples to adapt as needed:
'https://forum.solidworks.com/thread/60856
'ici le chemin vers le modèle de table de révision
Const TABLE_TEMPLATE As String = "C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\lang\french\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
Dim UserName As String
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
'On récupère le nom de session: prenom.nom, on supprime le . séparateur et on ajoute les majuscule en début de chaque mot
swRevTableAnn.AddRevision "A"
UserName = Environ("USERNAME")
UserName = Replace(UserName, ".", " ")
UserName = StrConv(UserName, vbProperCase)
'on ajoute les données dans le tableau
swTableAnn.Text(2, 4) = UserName
swTableAnn.Text(2, 3) = DateValue(Now)
swTableAnn.Text(2, 2) = "Modifications effectuées"
End If
End Sub
And also:
'**********************
'Copyright(C) 2020 www.codestack.net
'Reference: https://www.codestack.net/solidworks-api/document/drawing/clear-revision-table-new-revision/
'License: https://www.codestack.net/LICENSE.md
'**********************
Dim swApp As SldWorks.SldWorks
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Sub main()
Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc
If Not swDraw Is Nothing Then
Set swSheet = swDraw.GetCurrentSheet
Dim swRevTable As SldWorks.RevisionTableAnnotation
Set swRevTable = swSheet.RevisionTable
If Not swRevTable Is Nothing Then
'ClearRevisionTable swRevTable
AddRevision swRevTable, "001", Array("Sample Zone", "", "Description", "", "Admin")
Else
MsgBox "There is no revision table in the drawing"
End If
Else
MsgBox "Plase open the drawing"
End If
End Sub
Sub ClearRevisionTable(swRevTable As SldWorks.RevisionTableAnnotation)
Dim swTableAnn As SldWorks.TableAnnotation
Set swTableAnn = swRevTable
Dim i As Integer
For i = swTableAnn.RowCount - 1 To 0 Step -1
Dim revId As Long
revId = swRevTable.GetIdForRowNumber(i)
If revId <> 0 Then
swRevTable.DeleteRevision revId, True
End If
Next
End Sub
Sub AddRevision(swRevTable As SldWorks.RevisionTableAnnotation, revName As String, rowData As Variant)
Dim i As Integer
Dim swTableAnn As SldWorks.TableAnnotation
Set swTableAnn = swRevTable
swRevTable.AddRevision revName
For i = 0 To UBound(rowData)
If rowData(i) <> "" Then
swTableAnn.Text(swTableAnn.RowCount - 1, i) = rowData(i)
End If
Next
End Sub