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

Josh Brady wrote:
Any reason you don't want to link a note to$PRP:"SW-Current_Sheet"?
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
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
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