Adding an automatic page number to the title block

Hi all

I have a question about automatic properties in a 2D plane:

I would simply like to display the active page as well as the total number of pages in my drawing:
image

I proceeded as below:
I have two automatic fields in my title block, the first is to know the active page number. I simply inserted the " Sheet Number" attribute link in the desired box:

Then, in a second field, I would like to have the total number of pages.
There is indeed an attribute link with the total number of sheets:

The problem is that in this counter all the layers are taken into account, but I would like the " detail layer" to be excluded from this counter.

Do you know if this very special requette exists?
Maybe you have another method to display the page counter on a title block?

Thank you in advance for your feedback.

Hello;

To display the total number of sheets, use the "SW-Total Sheets" or "SW-Total Sheets" variable

https://help.solidworks.com/2020/french/SolidWorks/sldworks/t_link_notes_to_document_properties.htm

On the other hand, to be able to exclude a leaf according to a specific criterion I think you will have to go through a macro.
of the genre:


    Sub main()
        Dim swApp                   As SldWorks.SldWorks
        Dim swModel                 As SldWorks.ModelDoc2
        Dim swDraw                  As SldWorks.DrawingDoc
        Dim swSheet                 As SldWorks.Sheet
        Dim vSheetNames             As Variant
        Dim bRet                    As Boolean
        Dim i                       As Long

        Set swApp = Application.SldWorks
        Set swModel = swApp.ActiveDoc
        Set swDraw = swModel
        Set swSheet = swDraw.GetCurrentSheet
        vSheetNames = swDraw.GetSheetNames
       

        For i = 0 To UBound(vSheetNames)
            Debug.Print "  SheetName[" & i & "] = " & vSheetNames(i)           

           If vSheetNames(i) = "LE NOM DE LA FEUILLE A NE PAS COMPTER" Then 
            swModel.AddCustomInfo2 "Total Sheets", swCustomInfoText, swModel.GetSheetCount - 1                    

                 End 
                 End If

    Next i    

    End Sub

Kind regards.

1 Like

Thank you for your feedback, unfortunately I'm on Catia, and I think it's not applicable... :confused:

Hello;

Ah! Sapristi! I hadn't noticed the software I was using.
Sorry... :crazy_face:
Some probable leads here (it's good for CATIA this time):

Kind regards.

2 Likes

Hello

Probably too late but...

[optional, this is so that we have the same thing in step 2] // Instead of your " / " write " -/- " in the text box:
image

Rename the text box to PageNumber

The macro that is going well (normally):
Private Sub CommandButtonValider_Click()

Dim Planche, SurPlanches

' determines the total number of plates
SurPlanches = 0
For I = 1 TB CATIA. ActiveDocument.Sheets.Count
If CATIA. ActiveDocument.Sheets.Item(I). IsDetail = False Then
SurPlanches = SurPlanches + 1
End If
Next

' Assigning the page number
Board = 0
For I = 1 TB CATIA. ActiveDocument.Sheets.Count
If CATIA. ActiveDocument.Sheets.Item(I). IsDetail = False Then
Board = Board + 1
CATIA. ActiveDocument.Sheets.Item(I). Views.Item(2). Texts.GetItem(" PageNumber "). Text = Plate & " / " & SurPlanches

' renames tabs
CATIA. ActiveDocument.Sheets.Item(I). Name = Plate & " / " & OnPlates

End If

Next

End Sub

I'll let you get back in shape, I've removed everything that is useless, which explains why we're in a " private ", why there are " next " people who walk around...