Code:
Sub SUB_OneComponent()
Dim CATIA As INFITF.Application
CATIA = System.Runtime.InteropServices.Marshal.GetActiveObject("CATIA.Application") Dim oSel As Selection
Dim oProd As Object = ""
Dim oObject As Object
Dim E As Object
Dim Component(0)
Component(0) = "Product"
oSel = CATIA.ActiveDocument.Selection
oSel.Clear()
E = oSel.SelectElement2(Component, "################### Choose a Component #####################", False)
If E = "Normal" Then
If oSel.Count2 > 0 Then
oObject = oSel.Item(1).Value
Select Case oSel.Item(1).Type
Case Is = "PartDocument"
oProd = oObject.Product
Case Is = "Product"
oProd = oObject
Case Is = "Part"
oProd = oObject.Parent.Product
Case Else : MsgBox("something other than a part selected")
End Select
CATIA.StartCommand("Externalize product")
SendKeys.Send("{ENTER}")
Else
MsgBox("nothing selected")
End If
End If
oSel.Clear()
End Sub
Sub SUB_SubComponent()
Dim CATIA As INFITF.Application
CATIA = System.Runtime.InteropServices.Marshal.GetActiveObject("CATIA.Application")
Dim oSel As Selection
Dim oProd As Object = ""
Dim oObject As Object
Dim E As Object
Dim Component(0)
Component(0) = "Product"
oSel = CATIA.ActiveDocument.Selection
oSel.Clear()
E = oSel.SelectElement2(Component, "################### Choose a Component #####################", False)
If E = "Normal" Then
If oSel.Count2 > 0 Then
oObject = oSel.Item(1).Value
Select Case oSel.Item(1).Type
Case Is = "PartDocument"
oProd = oObject.Product
Case Is = "Product"
oProd = oObject
Case Is = "Part"
oProd = oObject.Parent.Product
Case Else : MsgBox("something other than a part selected")
End Select
CATIA.StartCommand("Externalize all sub products")
SendKeys.Send("{ENTER}")
Else
MsgBox("nothing selected")
End If
End If
oSel.Clear()
End Sub