I would like to get the Part Number
from Selection
. I guess because I get the info from Enovia5 so I encounter an issue: some I can get the Part Number
and some return Catastrophic failure
. I ensure the selection always has 1 item only.
CATIA.ActiveDocument.Selection.Item(1).LeafProduct.PartNumber '<~~~ sometimes works, sometimes does not.
Note: I use TypeName
to check what type of file gets selected, all return Document
but the ones return error actually have .CATPart
when I view their properties. Error mismatch will return if I try to declare it as Part or PartDocument.
Dim myPart as Part
Set myPart = CATIA.ActiveDocument.Selection.Item(1).value '<~~~ Mismatch
Set myPart = CATIA.ActiveDocument.Selection.Item(1).LeafProduct'<~~~ Mismatch
Dim myPartDoc as PartDocument
Set myPart = CATIA.ActiveDocument.Selection.Item(1).value '<~~~ Mismatch
Set myPart = CATIA.ActiveDocument.Selection.Item(1).LeafProduct'<~~~ Mismatch