CATIA V5 to .NET (VB.NET)

Lur Aldaraborda

CATIA V5 to .NET (VB.NET)

Hi everyone,

I have an issue due to the connection betwen CATIA V5 and .net, VB.net specifically. My problem is that I am not able to start programing and using CATIA APIs in VB.net, because my programs run into an error everytime I pass from INFITF,( example INFITF.Document) to MECMOD (example, Part). Same with Product and other references. The error seems to be always the same: " Product or Part not referenced in Product sesion"

Especifications: 

CATIA V5 6R2020

R29

All CATIA COM references added to Visual Studio 2019, all are R29

The VB.NET code:

Imports INFITF
Imports MECMOD

'*********************************************************************************************************************
'If I use INFITF all the time Im able to do little tasks, as read ActiveDocument name or create Parts and Products.
'But no more. INFITF case example
'*********************************************************************************************************************
Dim CATIA As INFITF.Application 'Note: INFITF is not neccesary because I imported it
Sub Main()
CATIA = CreateObject("CATIA.Application")

Dim activeDocument As Document
activeDocument = CATIA.ActiveDocument
MsgBox(activeDocument.Name) 'Everything Ok I do this to confirm that Im working with the correct file

'I can create products or Parts
Dim Product1 As Document
Product1 = CATIA.Documents.Add("Product")
Product.SaveAs("C:\PUT_YOUR_OWN_PATH" & "CoeForum.CATProduct") ' I can save and change names

End Sub()
'But when I am about to start using MECMOD or ProductStructureTypeLib, starts failing
Imports INFITF
Imports MECMOD

Dim CATIA As INFITF.Application 'Note: INFITF is not neccesary because I imported it
Sub Main()
CATIA = CreateObject("CATIA.Application")

Dim activeDocument As Document
activeDocument = CATIA.ActiveDocument
MsgBox(activeDocument.Name) 'Everything Ok I do this to confirm that Im working with the correct file

Dim part1 As Part
Part1 = activeDocument.Part 'ERROR I DONT KNOW HOW TO STOP USING INFITF.document AND START USING Part
MsgBox (Part1.Name)':( Dont work
End Sub()

I have tried also with Object instedad of INFITF but with the same result.

I will upload this thread in case I find a solution. 

Thanks