I'm trying to open a CATIA Drawing file with VB.NET (I'm using Visual Studio 2019) in order to edit some parameters, eventhough the file does open successfully the code block right on the opening line.
Error message pops-up at this line: (the file still opens successfully)
drawingDoc1 = doc1.Open("E:\TEMP\Drawings\D18-050022707.CATDrawing")
Error message:
System.InvalidCastException: 'Unable to cast COM object of type 'System.__ComObject' to interface type 'MECMOD.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{818C8B33-806B-0000-0280-030D3B000000}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
The code works for opening a CATPart but not CATDrawing or CATProduct, so my guess is the interface "MECMOD.Part" can be used only for CATPart, but what should be the interface for CATDrawing or CATProduct ?
I have added all CATIA references.
Dim CATIA As INFITF.Application
Try
CATIA = GetObject(, "CATIA.Application")
Catch
CATIA = CreateObject("CATIA.Application")
End Try
CATIA.Visible = True
CATIA.DisplayFileAlerts = True
Dim doc1 As INFITF.Documents
doc1 = CATIA.Documents
Dim drawingDoc1 As MECMOD.PartDocument
CATIA.DisplayFileAlerts = False
drawingDoc1 = doc1.Open("E:\TEMP\Drawings\D18-050022707.CATDrawing")
User contributions licensed under CC BY-SA 3.0