There is not a direct property/method to toggle [isolate] or [undo isolate]. But you could select the occurrence and execute the commands.
The code below toggle [isolate] on an occurrence, and save it to a *.stp file. Then toggle [undo isolate].
Private Sub test( )
Dim inventorAppType As Type =
System.Type.GetTypeFromProgID("Inventor.Application")
Dim _invApp As Inventor.Application =
System.Runtime.InteropServices.Marshal.
GetActiveObject("Inventor.Application")
If _invApp.Documents.Count = 0 Then
MsgBox("Need to open an Assembly document")
Return
End If
If _invApp.ActiveDocument.DocumentType <> _
DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("Need to have an Assembly document active")
Return
End If
Dim asmDoc As AssemblyDocument
asmDoc = _invApp.ActiveDocument
If asmDoc.SelectSet.Count = 0 Then
MsgBox("Need to select a Part or Sub Assembly")
Return
End If
Dim selSet As SelectSet
selSet = asmDoc.SelectSet
Dim compOcc As ComponentOccurrence
For Each obj In selSet
If TypeOf obj is ComponentOccurrence then
compOcc = obj
If TypeOf compOcc.Definition.Document Is
PartDocument Then
Dim oCtrlDef As ControlDefinition
'isolate
oCtrlDef =
_invApp.CommandManager.
ControlDefinitions.Item("AssemblyIsolateCmd")
' to run the command synchronously
oCtrlDef.Execute2(true)
Dim oDoc As Document
' it is still assembly context.
'So active document is still the assembly
' get the corresponding part document.
oDoc = compOcc.Definition.Document
Dim oFilename As String
' because ': ' is not accepted,
' you need to write a function to filter the char
' for simple test, this code uses the part file name
'oFilename = compOcc.Name & ".stp"
oFilename = oDoc.DisplayName & ".stp"
Dim oFilepath As String
oFilepath = "c:\temp\"
Dim oPathName As String
oPathName = oFilepath & oFilename
'export step
Call oDoc.SaveAs(oPathName, True)
'undo isolate
oCtrlDef =
_invApp.CommandManager.
ControlDefinitions.Item("AssemblyIsolateUndoCmd")
' to run the command synchronously
oCtrlDef.Execute2(true)
End If
End If
Next
End Sub