If it's useful to anyone, I run this from Part or Assembly level to modify ALL parts to ISO view of Thumbnail. Enjoy.
Public Sub Main()
If ThisApplication.ActiveDocumentType = DocumentTypeEnum.kPartDocumentObject Then
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Try
'set iproperty to use ISO view on save
oDoc.SetThumbnailSaveOption _
(ThumbnailSaveOptionEnum.kActiveComponentIsoViewOnSave)
'save the file
oDoc.Save
Catch
End Try
ElseIf ThisApplication.ActiveDocumentType = DocumentTypeEnum.kAssemblyDocumentObject
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oFileInfo As String = oDoc.FullFileName
Dim result = MessageBox.Show("You're running multiple parts in this Assembly " & vbCr & fileName & vbCr & "Do you want to continue??", "Run GS and Other Rules", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
If result = vbOK Then
RunExternalRules
Else
Return
End If
Dim oProgressBar As Inventor.ProgressBar
oProgressBar = ThisApplication.CreateProgressBar(False, PartCount, oMessage, True)
End If
End Sub
Sub RunExternalRules
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim iDoc As Document
'Set counter for counting parts
Dim iPartCount As Integer
iPartCount = 0
'Progress bar
oMessage = "Editing All Parts And Saving, Please Wait..."
PartCount = oDoc.AllReferencedDocuments.Count
Dim oProgressBar As Inventor.ProgressBar
oProgressBar = ThisApplication.CreateProgressBar(False, PartCount, oMessage, True)
Dim assembly As Inventor.AssemblyDocument = ThisDoc.Document
'Iterate through all of the occurrences in the assembly
For Each iDoc In oDoc.AllReferencedDocuments
iPartCount = iPartCount + 1
Dim fileName As String = IO.Path.GetFileNameWithoutExtension(iDoc.FullFileName)
'Update the progress bar
'If UserWantsToCancel Then Return
oProgressBar.Message = ("Working on part " & iPartCount & " of " & PartCount & " | " & fileName)
oProgressBar.UpdateProgress
Try
ThisApplication.Documents.Open(iDoc.FullFileName)
'set iproperty to use ISO view on save
IDoc.SetThumbnailSaveOption _
(ThumbnailSaveOptionEnum.kActiveComponentIsoViewOnSave)
'save the file
iDoc.Save
iDoc.Close
Catch
iDoc.Close
End Try
Next
oProgressBar.Close
End Sub
Private Function UserWantsToCancel(oprogressBar As Inventor.ProgressBar)
If (UserClickedOnCancel) Then
MsgBox("User clicked cancel and it has been detected now.")
' Add code here for clean exit of the rule.
' If you work with transactions then this could be
' the place To role back any changes
oprogressBar.Close()
Return True
End If
Return False
End Function