CATIA.Windows Error. Possible V5 vs. 3DX conflict

Ryan Binter

CATIA.Windows Error. Possible V5 vs. 3DX conflict

I am getting error 430 "Class does not support Automation or does not support expected interface" when running this simple macro in the V5 visual basic editor.


 

Sub CATMain()
Dim Wins As Windows
Set Wins = CATIA.Windows 'This line throws error 430
End Sub

Sub CATMain()
Dim App As Application
Set App = CATIA 'this line runs fine

Dim Wins As Windows
Set Wins = App.Windows 'this line throws error 430
End Sub

I noticed that the issue arose when I referenced the Windows object not when I referenced the CATIA Application object. I looked at the V5 automation documentation and saw that the Windows object is part of the InfInterfaces Framework and opened up the Tools>References menu in the VBA editor and saw that the file path to the CATIA INFInterfacesTLB Object Library was not referencing the same file path as my other V5 references.

CATIA INFInterfacesTLB Object Library Is located in C:\Program Files\Dassault Systemes\B421\win_b64\code\bin

My other V5 references are located in C:\Catia\B20B\win_b64\code\bin

 

I suspect that the issue is that VBA is trying to use 3DX versions of the library instead of the V5 version of the library since it is newer. Is there a way i can manually change the reference to the InfInterfaces library in the V5 folder without uninstalling 3DX?

 

Josh Bender

RE: CATIA.Windows Error. Possible V5 vs. 3DX conflict
(in response to Ryan Binter)

I just tried both circumstances with V5 R2018. I don't have 3DX installed. No issues - so your guess is probably pretty good about it conflicting with the 3DX library.

Is the issue strictly due to the object definition? What if you changed Wins to type variant?

Another thing to look into - I don't have an object library called "INFInterfacesTLB" as an option in my reference library, but I do have CATIA V5 infInterfaces Object Library. Perhaps just removing that as a reference will fix the issue?

Ryan Binter

RE: CATIA.Windows Error. Possible V5 vs. 3DX conflict
(in response to Josh Bender)

Defining all the variables as object or as variant seemed to work for some reason so I guess I will be able to continue the macro I was working on however, I don't enjoy having to throw away intellisense and any compile-time error checking just to work around this issue. Thanks for the advice though. Others can easily do this if they run into the same issue.

I cant seem to find the CATIA V5 infInterfaces Object Library but removing the reference to CATIA INFInterfacesTLB Object Library didnt allow the program to compile since it no longer recognized the Application or Windows objects. 

 

This code ran just fine with or without any InfInterfaces references:


Sub CATMain()
Dim App As Object 'Application
Set App = CATIA

Dim Wins As Object 'Windows
Set Wins = App.Windows
End Sub

Dave Shaw

RE: CATIA.Windows Error. Possible V5 vs. 3DX conflict
(in response to Ryan Binter)

Ryan, did you ever find a solution to this issue?  I've had many problems with it and my only solution has been to uninstall 3dx.  I really need to keep it installed this time around.  But I have the same exact problem.  

-Dave

Josh Bender

RE: CATIA.Windows Error. Possible V5 vs. 3DX conflict
(in response to Dave Shaw)

Ryan/Dave,

 

I did just run into an issue automating V5 through Microsoft Excel a couple weeks ago. I didn't connect the dots until now. I realized that certain objects which have identical type names will cause that issue (ie V5 Sheet vs Excel Sheet). It's as if the compiler is choosing one type over the other. Perhaps that's why there is are the priority buttons within references? What if you move INFInterfacesTLB all the way to the bottom of the list?

 

I got around it in Excel by changing the types to variant, like you did. The compiler seems to be able to figure out the correct type that way. I set the type properly while I wrote my lines (for intellisense) and then changed it to Variant whenever I wanted to test/run.

Little Cthulhu

RE: CATIA.Windows Error. Possible V5 vs. 3DX conflict
(in response to Josh Bender)

Simply use full interface names prefixed with typelibrary name:

Dim CATIA as INFITF.Application

Dim Excel as Excel.Application