Message 1 of 15

Not applicable
03-09-2020
05:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I was browsing the entire forum and I found ilogic code, but it´s probably for old version.
I use Inventor 2020.
I have many drawing views in sheet. So I want iLogic code for automatic nameing the labels. Is possible to edit following code?
' Set a reference to the drawing document.' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oSheets As Sheets Dim Sheet As Inventor.Sheet Dim oViews As DrawingViews Dim oView As DrawingView For Each oSheet In oDrawDoc.Sheets 'For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews If oView.ViewType <> 10504 Then ' Not kProjectedDrawingViewType 'Get the full filename Of the view model Dim oModelFileName As String oModelFileName = oView.ReferencedDocumentDescriptor.ReferencedDocument.FullFileName 'MessageBox.Show("view model name" & oModelFileName, "Title") Dim oPartList As PartsList 'try and get the parts list form the table of this sheet Try oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1) Catch 'on error try and search all sheets for first found parts list 'iterate trough each sheet Dim i As Long For i = 1 To oDrawDoc.Sheets.Count If oDrawDoc.Sheets.Item(i).PartsLists.Count > 0 Then Exit For Next oPartList = oDrawDoc.Sheets.Item(i).PartsLists.Item(1) 'MessageBox.Show("parts list found on: " & i, "Title") End Try ' Iterate through the contents of the parts list. Dim j As Long For j = 1 To oPartList.PartsListRows.Count ' Get the current row. Dim oRow As PartsListRow oRow = oPartList.PartsListRows.Item(j) 'get filename of model in row Dim oRowFileName As String oRowFileName = oRow.ReferencedFiles.Item(1).FullFileName 'compare the filenames 'Performs a text comparison, based on a case-insensitive text sort order 'If strings equal returns 0 If StrComp(oModelFileName, oRowFileName, CompareMethod.Text)=0 Then 'Get the value of Item from the Parts List 'Row name needs to be case sensitive or use 1 for first 2 for second etc. oCell = oPartList.PartsListRows.Item(j).Item("Item") 'Row name needs to be case sensitive or use 1 for first 2 for second etc. 'get the value of text in cell Dim oItemValue As String oItemValue = oCell.Value 'Show the view label oView.ShowLabel = True 'format the text first line oStringItem = "<StyleOverride Underline='True' FontSize='0.35'> ITEM " & oItemValue & " </StyleOverride>" 'format the text second line oStringScale = "<Br/><StyleOverride FontSize='0.3'>(Scale <DrawingViewScale/>)</StyleOverride>" 'add to the view label oView.Label.FormattedText = oStringItem & oStringScale End If Next End If Next Next
Thank you very much.
Solved! Go to Solution.