Sheet Numbering Macro, is it possible?

I dabble in API time to time, I know just enough to bedangerous, wrote about 4 so far. Anyway before I dig into it I waswondering if it is feasible to make a macro to number all mysheets. Going off memory I know when ever I referenced a sheet Iwas able to reference the sheet by name or active sheet but I needan idea how I would lets say tell it to label the current sheet asone then automatically go to the next sheet and label it as 2 andso on.SolidworksApi macros
Answers 7
JB
JB 2009-02-06 Best Answer
Any reason you don't want to link a note to$PRP:"SW-Current_Sheet"?
JH
JH 2009-02-06

Josh Brady wrote:

 

Any reason you don't want to link a note to$PRP:"SW-Current_Sheet"?

I do... My drawings say sheet 1 of X, X is linked to thetotal of sheets so that is always right, and 1 is what ever thename of my drawing sheet is, hence why I would like them to say1,2,3, etc....
JB
JB 2009-02-06
So... you want to rename the sheets in the user interface,not add a notation to your actual sheets as printed? As in changethe text on the sheet tab at the bottom of the screen? So insteadof "Sheet1", "Sheet2", etc, you see "1", "2", etc?
SF
SF 2009-02-06
Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swDraw As ModelDoc2
Dim SelMgr As SelectionMgr
Dim swSheet As SldWorks.sheet
Dim vSheetNames As Variant
Dim i As Long

Sub main()

Set swApp = Application.SldWorks

Set swDraw = swApp.ActiveDoc
Set SelMgr = swDraw.SelectionManager

vSheetNames = swDraw.GetSheetNames

For i = 0 To UBound(vSheetNames)
swDraw.Extension.SelectByID2 vSheetNames(i), "SHEET", 0, 0, 0,False, 0, Nothing, 0
Set swSheet = SelMgr.GetSelectedObject6(1, -1)
swSheet.SetName i + 1
Next i

End Sub

JH
JH 2009-02-06
Thanks Luke! Works perfect
SF
SF 2012-06-06

Hello all,

I need to solve problem with total number of sheets. Our changes of the drawing are written to DCN. This is the last sheet of the file. "SW-Sheet Name(Sheet Name)" is always the same (DCN).

Example:

We have a drawing in revision A (drawing has 3 sheets). Now we will do some changes and revision B is prepared (3 sheets + new DCN sheet). Sheet numbering is automatically updated from 1of3, 2of3, 3of3 to 1of4, 2of4, 3of4, 4of4. However I do not want to count DCN into to "SW-Total Sheets(Total Sheets)".

Key characteristics:

- DCN is the last sheet

- DCN name is always the same

How I can adjust the function in the text box for page numbering?

SHEET $PRP:"SW-Current Sheet(Current Sheet)" of $PRP:"SW-Total Sheets(Total Sheets)"

Thanks in advance!

Michal

KR
KR 2012-06-06

Michal,

First, welcome to the forums.  Second, I would recommend that you post this question as a new topic rather than placing it at the end of an already answered topic.

As for your issue itself, you will not be able to use the "SW-Total Sheets(Total Sheets)" property.  Instead you should use IDrawingDoc::GetSheetCount to count up the number of sheets in the drawing and subtract 1.  Use that value in place of the Total Sheets property.

Keith

Video Tutorials for the SolidWorks API