Will programming knowledge in CATIA v5 translate to V6?
One question I am getting asked more and more is if CATIA V5 macro programming skills are going to be applicable in CATIA V6? My answer is the majority of the macros you write in V5 will not be able to be used in V6 as is. But the skills and knowledge required to write the codes in V5 will transfer to V6 and other programming languages as well. Learn more by reading on.
Quick Introduction to CATIA V6
The biggest difference between CATIA V6 and CATIA V5 is that it is server based, therefore it is required to search for a part or product before you can open it.
The second most noticeable difference is the silver layer. Simply put, it is a new environment that is accessed when you choose to “Explore” a product instead of opening it directly from the search window. It allows you see 3D thumbnails of the parts in a sort of turntable organized by the hierarchy. The main purpose of this layer is to allow you to visually choose and open a part, but it can also be used to open specific part(s) within a product that you want for very large assemblies. It has many other applications but to be concise those are the main two.
The environment where the product is opened is called the “Blue Layer”, basically the place where we are used to work in V5. The “3D Part” is equivalent to the CATProduct and CATPart we are used to. The “3D Shape” is what we call the Representation Reference or “Rep. Ref.” for short. Similar to V5 in the blue layer. Although, the measure tool and the constraints/mechanism creation are different.
CATIA V6 Macro Example
The following code is a CATIA V6 macro that will open parts using a txt file on the desktop. Notice how it is the same yet different to a code written for V5?
Sub CATMain ()
Dim partNumbers(100) As String
For i = 1 to 100
If partNumbers(i) <> "" Then
OpenProduct left(partNumbers(i), 15), right(partNumbers(i), 1)
Dim oFile As File
Set oFile = CATIA.FileSystem.GetFile ("C:\Users\yOuRnAmE\Desktop\PartNumbersTextFile.txt") Dim iStream As TextStream
Set iStream = oFile.OpenAsTextStream ("ForReading")For i = 1 to 100
partNumbers(i) = iStream.ReadLine
If iStream.AtEndOfStream = True Then Exit For
End SubSub OpenProduct (partNumber, version)
Set oSearchService = CATIA.GetSessionService ("PLMSearch")
Set oPLMSearch = oSearchService.Searches.Add
oPLMSearch.Type = "ProductDS" 'can be different for your company
oPLMSearch.AddAttributeCriteria "PLM_ExternalID", partNumber
oPLMSearch.AddAttributeCriteria "V_version", version
oPLMSearch.SearchDim cPLMEntities As PLMEntities
Set cPLMEntities = oPLMSearch.EditedContentDim oOpenService As PLMOpenService
Set oOpenService = CATIA.GetSessionService ("PLMOpenService")
Dim oEditor As Editor
oOpenService.PLMOpen cPLMEntities.Item(1), oEditor
Set OpenProductAndgetEditor = oEditor
I believe one of the best ways to learn something is to throw yourself into it head first. One way I believe you can learn more about writing VBA macros is to actually learn how to program in another language, such as Java. Why? When you learn multiple programming languages (or even spoken languages), you can’t help but identify similarities between them and in turn understand the foundations on which they’re built. I was about to create a simple Android application even though I have never taken a class or read a book about Java due to my CATIA programming knowledge. Even if you know you’re going to be moving on to CATIA V6 soon, it is still very beneficial to learn how to program in CATIA V5 first.
So yes, the actual code itself is different but the concepts and syntax are the same and can be applied not only to V6 but to any programming job.