Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iLogic to Name Drawing Sheet as Sheet Number

Anonymous

iLogic to Name Drawing Sheet as Sheet Number

Anonymous
Not applicable

I need help naming my sheets with the active sheets part number plus the sheet number. I have the part number portion working correctly but I cant get the sheet number portion to work. In the end I'm wanting my sheet name to look like "aaaaaab" (where as a=part number and b=sheet number).

 

Here is what I have so far:

 

SyntaxEditor Code Snippet

Dim oSheets As Sheets = ThisDrawing.Document.sheets
Dim oSheet As Sheet
Dim SheetNumber As Integer

For Each oSheet In oSheets
    oSheet.activate
    oModel = IO.Path.GetFileName(ActiveSheet.View("ISO").ModelDocument.FullFileName)
    'MessageBox.Show(oModel)
    oDoc = ThisDoc.Document
    SheetNumber  = Mid(oDoc.ActiveSheet.Name, InStr(1, oDoc.ActiveSheet.Name, ":") + 1)
    partnum = iProperties.Value(oModel, "Project", "Part Number")("SheetNumber")
    'MessageBox.Show(partnum)
    ActiveSheet.Sheet.Name = partnum
Next

 

 

0 Likes
Reply
Accepted solutions (1)
2,076 Views
6 Replies
Replies (6)

JaneFan
Autodesk
Autodesk

Hi, 

 

Please try using following code:

SyntaxEditor Code Snippet

Dim oSheets As Sheets = ThisDrawing.Document.sheets
Dim oSheet As Sheet
Dim SheetNumber As String 

For Each oSheet In oSheets
    oSheet.activate
    oModel = IO.Path.GetFileName(ActiveSheet.View("ISO").ModelDocument.FullFileName)

    'MessageBox.Show(oModel)
    oDoc = ThisDoc.Document
    MessageBox.Show (Mid(oDoc.ActiveSheet.Name, InStr(1, oDoc.ActiveSheet.Name, ":") + 1))
    SheetNumber  = Mid(oDoc.ActiveSheet.Name, InStr(1, oDoc.ActiveSheet.Name, ":") + 1)
    
    partnum = iProperties.Value(oModel, "Project", "Part Number")(Int(sheetnumber))
    MessageBox.Show (partnum )
    'MessageBox.Show(partnum)
    ActiveSheet.Sheet.Name = SheetNumber + partnum
Next

 




Jane Fan
Inventor QA Engineer
0 Likes

Anonymous
Not applicable

I'm getting a "1T" for sheet 1 and a "2S" for sheet 2's name. My part number is XXX-XXXXX-XX(sheet number here)

0 Likes

JaneFan
Autodesk
Autodesk
Accepted solution

Hello, 

 

Sorry, I must have misunderstood your intention.

Please let me know whether this is what you need: Name of partnumber + Sheet.index. 

 

SyntaxEditor Code Snippet

Dim oSheets As Sheets = ThisDrawing.Document.sheets
Dim oSheet As Sheet
Dim SheetNumber As String 

For Each oSheet In oSheets
    oSheet.activate
    oModel = IO.Path.GetFileName(ActiveSheet.View("ISO").ModelDocument.FullFileName)

    'MessageBox.Show(oModel)
    oDoc = ThisDoc.Document
    MessageBox.Show (Mid(oDoc.ActiveSheet.Name, InStr(1, oDoc.ActiveSheet.Name, ":") + 1))
    SheetNumber  = Mid(oDoc.ActiveSheet.Name, InStr(1, oDoc.ActiveSheet.Name, ":") + 1)
    
    partnum = iProperties.Value(oModel, "Project", "Part Number")
    MessageBox.Show (partnum )
    'MessageBox.Show(partnum)
    ActiveSheet.Sheet.Name = partnum + "-" + SheetNumber
Next

 




Jane Fan
Inventor QA Engineer

Anonymous
Not applicable

That worked perfect, thank you!

0 Likes

Anonymous
Not applicable
oModel = IO.Path.GetFileName(ActiveSheet.View("ISO").ModelDocument.FullFileName)

Can you write me what exacly should be write instead "ISO". I'm trying diferrents names, but I get: 'Sheet.View: Not found draw's name 'ISO'.

0 Likes

Anonymous
Not applicable

It works, when you want to give same text from first sheet (Part number) for all sheets. Do you know how get text from Part number for each sheets separatly?

0 Likes