- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am looking for a reasonably straightforward way to take the sheet names and sheet numbers from a drawing set and automatically put them into a table on sheet one of an Inventor drawing.
I am using the code below to link a titleblock field to the sheet title so the sheet has a global title and a specific per-sheet title/description
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oTitleBlock As TitleBlock
Dim oTextBox As TextBox
Dim oSheet As Sheet
Dim lPos As Long
Dim sSheetName As String
For Each oSheet In oDoc.Sheets
If oSheet.ExcludeFromCount = False Then
oTitleBlock = oSheet.TitleBlock
lPos = InStr(oSheet.Name, ":")
sSheetName = Left(oSheet.Name, lPos - 1)
For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
If oTextBox.Text = "SHEET-NAME" Then
Call oTitleBlock.SetPromptResultText(oTextBox, sSheetName)
End If
Next
Else
End If
Next
I considered exporting the sheet names and numbers to an excel file and then re-importing them but that seemed like it left more room for something to go wrong.
That said, I am stuck on moving that data into a table with a title (drawing index), 2 columns (Description and Sheet#) and adds as many rows as needed. I found a thread that referenced this code that I tried to modify but I am not able to get anything to display. Set up table with iLogic
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim sSheetName As String
oDoc = ThisDoc.Document
oSheet = oDoc.ActiveSheet
Dim oColumns As Integer
Dim oRows As Integer
oColumns = 2
i = 0
'tally the sheets that are set to be excluded
For Each oSheet In oDoc.Sheets
If oSheet.ExcludeFromCount = True Then
i = i + 1
Else
End If
Next
'subtract the excluded sheet from the number of sheets in the sheet collection
oMySheetCount = oDoc.Sheets.Count - i
oRows = 1 + oMySheetCount
'calculate number of columns cells
oCells = oColumns * oRows
Dim oTitles(oColumns - 1) As String
'Hardcoded titles
oTitles(0) = "DESCRIPTION"
oTitles(1) = "SHEET #"
Dim oContents(oCells - 1) As String
Dim j As Integer
j = 0
i = 1
Do Until j = oCells
'fill cell data
If j = 0 Then
oContents(j) = "Groef"
ElseIf j = 6 Then
oContents(j) = "Zetting"
ElseIf j = 7 Then
oContents(j) = "Aanslag"
ElseIf j = 8 Then
oContents(j) = "Zet Lengte"
ElseIf j = 9 Then
oContents(j) = i
i = i + 1
ElseIf j > 9
If j = 9 + (i - 1) * 3 Then
oContents(j) = i
i = i + 1
Else
oContents(j) = ""
End If
Else
oContents(j) = ""
End If
j = j + 1
Loop
Dim InsP As Point2d
InsP = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
Dim oCustomTable As CustomTable
oCustomTable = oSheet.CustomTables.Add("DRAWING INDEX", InsP, oColumns, oRows, oTitles, oContents)
I do not get any errors but I also do not get a table on the sheet or in the styles menu. In this application I think the loop is not needed but I wanted to see if I could get the code to work before stripping it out so I have left it in place for now.
Thanks,
Sean
Solved! Go to Solution.