Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

CATIA V5 and using VB6 1

Status
Not open for further replies.

RedCoat999

Mechanical
Oct 21, 2003
25
0
0
US
Can anyone tell me if you can use VB6 within CATIA V5? Natively it uses VBA which does not appear to use PropertyBag's.

If you can use VB6 within CATIA V5 then how do you do this?

Thanks
 
Replies continue below

Recommended for you

I prefer to use late-binding with VB6 and Catia. Although it is supposed to run slower, you'll find that it is Catia that runs slow and you won't notice the difference between early-binding and late-binding. If these terms are new to you they are covered in the VB docs, so you should read up on them.

The other advantage of late-binding is that you do not need to recompile code between Catia releases, unless the functionality that you are using has changed.

So, with late binding...

'In a module declaration section:
Global CATIA As Object

Then something like this:

Public Function GetCatia() As Boolean

GetCatia = False
If QUIT = False Then
If CATIA Is Nothing Then
On Error Resume Next
Set CATIA = GetObject(, "CATIA.Application")
If Err.Number <> 0 Then
msg = "Cannot find Catia. Please start Catia and then run the application."
msg = msg & vbCrLf & "Do you want to quit?"
res = MsgBox(msg, vbCritical + vbSystemModal + vbYesNo, "Cannot find Catia")
If res = vbYes Then
QUIT = True
End If
Else
GetCatia = True
End If
Else
GetCatia = True
End If
End If

End Function


If you want to use early binding you can find more information in the on-line documentation. See
V5Automation.chm in the bin directory of your Catia path for more information.

Andy
 
So basically, you are using VB6 to run CATIA if it is not running like any other program (I've used VB6 to run Word and Excel and Access before) and then controlling it with VB instead of CATIA controlling VBA.

Sounds good, thanks for the clear post with code. Code always helps!
 
Status
Not open for further replies.
Back
Top