Talou
Computer
- May 14, 2019
- 17
Hello,
I would like to know if the user selected the Part or the Product.
To go around the problem, I cast the object into a Part and if it’s fail I suppose I’m on the Product and I cast to the Product.
I would prefer to find what object I’m on before casting it.
Thank you,
Vincent;
Code:
Imports INFITF
Imports ProductStructureTypeLib
Imports MECMOD
Imports Microsoft.VisualBasic
Module Module1
Public CATIA As INFITF.Application
Public Doc As Document
Public Prod As ProductDocument
Public Part As Part
Public Prods As Products
Public pSel As Selection
Const iName As String = "Cleaning Harness"
Sub Main()
CATIA = CType(GetObject(, "CATIA.Application"), INFITF.Application)
Try
'Retrieve the Selection object
pSel = CATIA.ActiveDocument.Selection
'Get the object in the selection
Part = pSel.Item(1).Value
'Display message
MsgBox("Selected element: " & Part.Name)
Catch
MsgBox("Not a part.")
End Try
End Sub
End Module