Reference drawing sheet name with Ilogic

Reference drawing sheet name with Ilogic

SofiaGrave4819
Enthusiast Enthusiast
2,969 Views
15 Replies
Message 1 of 16

Reference drawing sheet name with Ilogic

SofiaGrave4819
Enthusiast
Enthusiast

Hi to all

i have some drawings with several sheets, and i would like to have in the first sheet some kind of index table where we have the sheet name and sheet page number.

could someone guide me?

 

thanks for your time and collaboration.

 

Sofia Grave

0 Likes
Accepted solutions (1)
2,970 Views
15 Replies
Replies (15)
Message 2 of 16

clutsa
Collaborator
Collaborator

Add a note to your first page and run this thru an iLogic rule

Dim app As Inventor.Application = ThisApplication
Dim doc As DrawingDocument = app.ActiveDocument
Dim Count As Integer = 1 'used to track sheets
Dim sheet1 As Sheet = doc.Sheets(1)
Dim myNote As String = "Index:" & vbCr 'how you want to start your note - "vbCr" starts a new line
For Each oSheet In doc.Sheets
	myNote = myNote & Count.ToString & ": " & oSheet.name & vbCr 'whatever the note is so far plus sheet count plus the sheet name plas a new line 
	Count = Count + 1 'incriment the count for the next line
Next
sheet1.DrawingNotes(1).Text = myNote 'set the note text - if more then one note is on the first page change the "(1)" to whatever number works
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 16

clutsa
Collaborator
Collaborator

This if you want to drop the ":#" from the sheet names

Dim app As Inventor.Application = ThisApplication
Dim doc As DrawingDocument = app.ActiveDocument
Dim Count As Integer = 1 'used to track sheets
Dim sheet1 As Sheet = doc.Sheets(1)
Dim myNote As String = "Index:" & vbCr 'how you want to start your note - "vbCr" starts a new line
Dim nameOnly As String
For Each oSheet In doc.Sheets
	nameOnly = Left(oSheet.name, InStr(oSheet.name,":")-1)
	myNote = myNote & Count.ToString & ": " & nameOnly & vbCr 'whatever the note is so far plus sheet count plus the sheet name plas a new line 
	Count = Count + 1 'incriment the count for the next line
Next
sheet1.DrawingNotes(1).Text = myNote 'set the note text - if more then one note is on the first page change the "(1)" to whatever number works
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 4 of 16

SofiaGrave4819
Enthusiast
Enthusiast

hi thanks for the feedback. it worked like a charm, i just made some twits here and there to suit my application.

but now i have another questions?

can i have this, instead of a note, in a symbol?

why i am asking is because i normally have more notes in the drawings and i didn't want to change constantly the note number in the code.

 

but i have to say that now is working.

thanks alot.

 

Sofia Grave

0 Likes
Message 5 of 16

clutsa
Collaborator
Collaborator

I could maybe figure that out what about a prompt that just asks you which note you'd like to use?

Dim app As Inventor.Application = ThisApplication
Dim doc As DrawingDocument = app.ActiveDocument
Dim Count As Integer = 1 'used to track sheets
Dim sheet1 As Sheet = doc.Sheets(1)
Dim myNote As String = "Index:" & vbCr 'how you want to start your note - "vbCr" starts a new line
Dim nameOnly As String
For Each oSheet In doc.Sheets
	nameOnly = Left(oSheet.name, InStr(oSheet.name,":")-1)
	myNote = myNote & Count.ToString & ": " & nameOnly & vbCr 'whatever the note is so far plus sheet count plus the sheet name plas a new line 
	Count = Count + 1 'incriment the count for the next line
Next
Dim noteToChange As DrawingNote = app.CommandManager.Pick(SelectionFilterEnum.kDrawingNoteFilter,"Which note is your index?")
noteToChange.Text = myNote 'set the note text - if more then one note is on the first page change the "(1)" to whatever number works
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 6 of 16

SofiaGrave4819
Enthusiast
Enthusiast
Accepted solution

Thanks it works perfectly.

i will make a few twits to fit more my application.

Thanks a lot for the great job.

Sofia Grave

0 Likes
Message 7 of 16

clutsa
Collaborator
Collaborator

Great! Glad I could help. Can you mark as accepted?

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 8 of 16

RogerCamp
Advocate
Advocate

I've been trying to implement your code according to my needs. The problem I have is that usually my drawing sets have more than 80 sheets and the code makes my sheet index to be bigger than the sheet. I'd like to break the list in two when it reaches 50 lines (sheets). From the first up to the 50th sheet, the code "prints" on myNote1 and from the 51st to the end on myNote 2. How can it be done?

Thanks.

0 Likes
Message 9 of 16

clutsa
Collaborator
Collaborator

So this isn't perfect if your notes are on different sheets but I made it so you can hit escape to skip placing a note. Run the rule on your first index page and escape to skip the second note then jump to your next index page and run the rule again. You can select the same note twice or escape the first time. I'll keep looking for a way to change pages while the code is running but this is a start.

Dim app As Inventor.Application = ThisApplication
Dim doc As DrawingDocument = app.ActiveDocument
Dim Count As Integer = 1 'used to track sheets
Dim PerPage As Integer = 50 'max number of sheets per note
Dim notesRequired As Integer = doc.Sheets.Count / PerPage
Dim sheet1 As Sheet = doc.Sheets(1)
Dim myNote(notesRequired) As String 
For i = 0 To notesRequired - 1
	myNote(i) = "Index:" & vbCr 'how you want to start your note - "vbCr" starts a new line
Next
Dim nameOnly As String
Dim n As Integer = 0
For Each oSheet In doc.Sheets
	nameOnly = Left(oSheet.name, InStr(oSheet.name,":")-1)
	myNote(n) = myNote(n) & Count.ToString & ": " & nameOnly & vbCr 'whatever the note is so far plus sheet count plus the sheet name plus a new line 
	If Count Mod PerPage = 0 Then n = n + 1 'next note if needed
	Count = Count + 1 'incriment the count for the next line
	
Next
For i = 0 To notesRequired - 1	
	Dim noteToChange As DrawingNote = app.CommandManager.Pick(SelectionFilterEnum.kDrawingNoteFilter,"Which note is your " & i.tostring() & " index?")
	If not noteToChange is nothing then noteToChange.Text = myNote(i) 'set the note text - 
Next

 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 10 of 16

RogerCamp
Advocate
Advocate

Thank you for your reply.

I gotta it working by making some adjustments in the original code.

What I did was:

1) Separated the output in two columns. One is for the SheetName, another for SheetNumber, so they are aligned to the left.

 

2) I created a Sheet with a grid using Sketch Symbol, placed on an empty sheet, placed the 6 notes on the first row, and then created a Sheet Format on my template.

 

Annotation 2020-05-23 171506.png

 

3) I created a form to input the Sheet Number referencing to the actual Sheet Index. I still have to input it manually, cause it can change from set to set. Usually it is sheet 3. The form runs the iLogic when you press ok, the input is carried over a parameter called SheetNumber and the rule reads the number from that parameter.

 

Annotation 2020-05-23 171130.pngAnnotation 2020-05-23 171307.png

4) On the sheet index, there are 6 notes:

myNote1 = Sheet Name, from 1 to 50

myNote2 = Sheet Number, from 1 to 50

myNote3 = Sheet Name, from 51 to 100

myNote4 = Sheet Number, from 51 to 100

myNote5 = Sheet Name, from 101 to 150

myNote6 = Sheet Number, from 101 to 150

 

5) The code reads the sheets quantity and applies it accordingly.

 

Here's the code:

Dim oSheetNumber As Integer = Parameter("SheetNumber")
Dim app As Inventor.Application = ThisApplication
Dim doc As DrawingDocument = app.ActiveDocument
Dim Count As Integer = 1 'used to track sheets

oMySheetCount = doc.Sheets.Count - i

Dim lPos As Long
Dim sSheetName As String

Dim project_number As String = Category 'used along the SheetNumber, it comes from the Drawing iProperty
Dim sheet1 As Sheet = doc.Sheets(oSheetNumber)
Dim myNote1 As String
Dim myNote2 As String
Dim myNote3 As String
Dim myNote4 As String
Dim myNote5 As String
Dim myNote6 As String

If oMySheetCount <= 50 Then
For Each oSheet In doc.Sheets
	If Count <= 50 Then
	lPos = InStr(oSheet.Name, ":")
	sSheetName = Left(oSheet.Name, lPos - 1)
	myNote1 = myNote1 & sSheetName & vbCr
	myNote2 = myNote2 & project_number & "-" & Count & vbCr
	Count = Count + 1
	Else
	End If
Next
sheet1.DrawingNotes(1).Text = myNote1
sheet1.DrawingNotes(2).Text = myNote2
sheet1.DrawingNotes(3).Text = ""
sheet1.DrawingNotes(4).Text = ""
sheet1.DrawingNotes(5).Text = ""
sheet1.DrawingNotes(6).Text = ""
End If

If oMySheetCount > 50 And oMySheetCount <= 100 Then
For Each oSheet In doc.Sheets
	If Count <= 50 Then
	lPos = InStr(oSheet.Name, ":")
	sSheetName = Left(oSheet.Name, lPos - 1)
	myNote1 = myNote1 & sSheetName & vbCr
	myNote2 = myNote2 & project_number & "-" & Count & vbCr
	Count = Count + 1
	ElseIf Count <= 100 Then
	lPos = InStr(oSheet.Name, ":")
	sSheetName = Left(oSheet.Name, lPos - 1)
	myNote3 = myNote3 & sSheetName & vbCr
	myNote4 = myNote4 & project_number & "-" & Count & vbCr
	Count = Count + 1
	End If		
Next
sheet1.DrawingNotes(1).Text = myNote1
sheet1.DrawingNotes(2).Text = myNote2
sheet1.DrawingNotes(3).Text = myNote3
sheet1.DrawingNotes(4).Text = myNote4
sheet1.DrawingNotes(5).Text = ""
sheet1.DrawingNotes(6).Text = ""
End If

If oMySheetCount > 100 Then
For Each oSheet In doc.Sheets
	If Count <= 50 Then
	lPos = InStr(oSheet.Name, ":")
	sSheetName = Left(oSheet.Name, lPos - 1)
	myNote1 = myNote1 & sSheetName & vbCr
	myNote2 = myNote2 & project_number & "-" & Count & vbCr
	Count = Count + 1
	ElseIf Count <= 100 Then
	lPos = InStr(oSheet.Name, ":")
	sSheetName = Left(oSheet.Name, lPos - 1)
	myNote3 = myNote3 & sSheetName & vbCr
	myNote4 = myNote4 & project_number & "-" & Count & vbCr
	Count = Count + 1
	ElseIf Count <= 150 Then
	lPos = InStr(oSheet.Name, ":")
	sSheetName = Left(oSheet.Name, lPos - 1)
	myNote5 = myNote5 & sSheetName & vbCr
	myNote6 = myNote6 & project_number & "-" & Count & vbCr
	Count = Count + 1
	End If
Next
sheet1.DrawingNotes(1).Text = myNote1
sheet1.DrawingNotes(2).Text = myNote2
sheet1.DrawingNotes(3).Text = myNote3
sheet1.DrawingNotes(4).Text = myNote4
sheet1.DrawingNotes(5).Text = myNote5
sheet1.DrawingNotes(6).Text = myNote6
End If

I hope it can be useful to others.

 

Cheers!

0 Likes
Message 11 of 16

bpgronhoff
Participant
Participant

This is great works well, I am trying to get it to add it to the border on my cover page so that someone cant move or delete it and I keep getting errors. Any help would be great!

Message 12 of 16

clutsa
Collaborator
Collaborator

This was a head scratcher. You'll need a separate border (with a textbox pre-inserted where you want your index) for your sheet:1 then all the other sheets or the "index" will be on every page. This is of course based off the first bit of code I made but the idea of how to edit a textbox in the border is here.

Dim app As Inventor.Application = ThisApplication
Dim doc As DrawingDocument = app.ActiveDocument
Dim Count As Integer = 1 'used to track sheets
Dim sheet1 As Sheet = doc.Sheets(1)
Dim myNote As String = "Index:" & vbCr 'how you want to start your note - "vbCr" starts a new line
Dim nameOnly As String
Dim tg As TransientGeometry = app.TransientGeometry
For Each oSheet In doc.Sheets
	nameOnly = Left(oSheet.name, InStr(oSheet.name,":")-1)
	myNote = myNote & Count.ToString & ": " & nameOnly & vbCr 'whatever the note is so far plus sheet count plus the sheet name plas a new line 
	Count = Count + 1 'incriment the count for the next line
Next
sheet1.Border.Definition.Edit(doc.BorderDefinitions.Item(2).Sketch) 'change item number as needed
Try
	Dim mySketch As DrawingSketch = doc.ActivatedObject 'had a terrible time figuring this line out
	mySketch.TextBoxes(1).Text = myNote
	'myTextBox = mySketch.TextBoxes.AddByRectangle(tg.CreatePoint2d(0, 0), tg.CreatePoint2d(10, 10), MyNote) 'if you don't have a pre-made text box use this
	sheet1.Border.Definition.ExitEdit(True)
Catch ex As Exception
	Logger.Debug("Error: {0}",ex.ToString)
	sheet1.Border.Definition.ExitEdit(True)
End Try

 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 13 of 16

bpgronhoff
Participant
Participant
Awesome I will give it a shot, I already have a special border for my cover page. The next step is to write and "If" for it t oread the "page description" and add a Predefined letter with its corresponding seq number.
Thank you!!
Message 14 of 16

bpgronhoff
Participant
Participant

Ok, so instead of adding it to the border I have it in a text box like before. Then I modified it so that it will index them using an If statement. So the Page displays as C1 - Cover etc. 

Dim app As Inventor.Application = ThisApplication
Dim doc As DrawingDocument = app.ActiveDocument
Dim Count As Integer = 1 'used to track sheets
Dim sheet1 As Sheet = doc.Sheets(1)
Dim nameOnly As String
For Each oSheet In doc.Sheets
	nameOnly = Left(oSheet.name, InStr(oSheet.name, ":") -1)
	
If nameOnly = "Cover Sheet" Then
	myNote = myNote & "C" & Count.ToString &" "& nameOnly & vbCr 'add letter For Sheet with count then space then page name plus newline
	Count = Count + 1 'incriment the count for the next line
	
ElseIf nameOnly = "Suggested Suspension Plan" Then
	myNote = myNote & "S" & Count.ToString &" "& nameOnly & vbCr 'add letter For Sheet with count then space then page name plus newline 
	Count = Count + 1 'incriment the count for the next line
	
ElseIf nameOnly = "Floor Plan" Then
	myNote = myNote & "F" & Count.ToString &" "& nameOnly & vbCr 'add letter For Sheet with count then space then page name plus newline 
	Count = Count + 1 'incriment the count for the next line
	
ElseIf nameOnly = "Details" Then
	myNote = myNote & "D" & Count.ToString &" "& nameOnly & vbCr 'add letter For Sheet with count then space then page name plus newline
	Count = Count + 1 'incriment the count for the next line
	
ElseIf nameOnly = "Product/Panel Info" Then
	myNote = myNote & "P" & Count.ToString &" "& nameOnly & vbCr 'add letter For Sheet with count then space then page name plus newline 
	Count = Count + 1 'incriment the count for the next line
ElseIf nameOnly = "RCP" Then
	myNote = myNote & "R" & Count.ToString &" "& nameOnly & vbCr 'add letter For Sheet with count then space then page name plus newline 
	Count = Count + 1 'incriment the count for the next line
	
ElseIf nameOnly = "Reflected Ceiling Plan" Then
	myNote = myNote & "R" & Count.ToString &" "& nameOnly & vbCr 'add letter For Sheet with count then space then page name plus newline 
	Count = Count + 1 'incriment the count for the next line
	
ElseIf nameOnly = "Elevation" Then
	myNote = myNote & "E" & Count.ToString &" "& nameOnly & vbCr 'add letter For Sheet with count then space then page name plus newline 
	Count = Count + 1 'incriment the count for the next line

ElseIf nameOnly = "Panel Drawings" Then
	myNote = myNote & "P" & Count.ToString &" "& nameOnly & vbCr 'add letter For Sheet with count then space then page name plus newline 
	Count = Count + 1 'incriment the count for the next line

ElseIf nameOnly <> "" Then
	myNote = myNote & PageName & Count.ToString & " " & nameOnly & vbCr 'whatever the note is so far plus sheet count plus the sheet name plas a new line 
Count = Count + 1 'incriment the count for the next line

End If


Next
sheet1.DrawingNotes(1).Text = myNote 'set the note text - if more then one note is on the first page change the "(1)" to whatever number works 

 

 

0 Likes
Message 15 of 16

bpgronhoff
Participant
Participant

So the next step I'm hitting a wall, Im trying to strip it out so that I get just the current page to display and not the entire list of pages, I can get it to work on page 1, but not on any other page. They all report as the first page, I know Im missing something small.

Dim app As Inventor.Application = ThisApplication
Dim doc As DrawingDocument = app.ActiveDocument
Dim Count As Integer = 1 'used to track sheets

	nameOnly = Left(ActiveSheet.Name, InStr(ActiveSheet.Name, ":") -1)
	
If nameOnly = "Cover Sheet" Then
	myNote = myNote & "C" & Count 
		
ElseIf nameOnly = "Suggested Suspension Plan" Then
	myNote = myNote & "S" & Count  
		
ElseIf nameOnly = "Floor Plan" Then
	myNote = myNote & "F" & Count 
		
ElseIf nameOnly = "Details" Then
	myNote = myNote & "D" & Count
	
	
ElseIf nameOnly = "Product/Panel Info" Then
	myNote = myNote & "P" & Count
	
ElseIf nameOnly = "RCP" Then
	myNote = myNote & "R" & Count 
		
ElseIf nameOnly = "Reflected Ceiling Plan" Then
	myNote = myNote & "R" & Count
		
ElseIf nameOnly = "Elevation" Then
	myNote = myNote & "E" & Count 
	
ElseIf nameOnly = "Panel Drawings" Then
	myNote = myNote & "P" & Count 
	
ElseIf nameOnly <> "" Then
	myNote = myNote & PageName & Count  

End If
Count = Count + 1

SHEETNO = myNote

 

0 Likes
Message 16 of 16

hamed_nemati
Participant
Participant

Hello to everyone,

How can i add sheet metal thickness to inventor drawing sheet name by using ilogic?

0 Likes