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

iLogic to Name Drawing Sheet as Sheet Number

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

 

 

Tags (1)
JaneFan
in reply to: Anonymous

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
Anonymous
in reply to: JaneFan

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)

JaneFan
in reply to: Anonymous

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
in reply to: JaneFan

That worked perfect, thank you!

Anonymous
in reply to: Anonymous

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'.

Anonymous
in reply to: Anonymous

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?