CATIA V6 can be automated in the same way like CATIA V5. You need either the comtypes module or the Pywin32 module. The next two examples show two simple programming examples by using Pywin32, which is included in the ActivePython Distribution. If you want to use another Python Distribution, you have to install this module manually.
When you run the following two scripts, CATIA V6 should be installed and already be running.
The first example prints the names (PLMExternalID) of all selected entries in a query list of the advanced search (Silver Layer):
for i in range(catiaObj.ActiveEditor.Selection.Count):
print 'Selected Item %s: %s'%(i, catiaObj.ActiveEditor.Selection.Item(i + 1).Value.Name)
The next example throws a query (Weld0815*) to the VPM database, gets all relevant products and places all of them on a turntable view of the Silver Layer. This is very useful, if you want to compare different Products an one turntable view.
# Search for every Product with name Weld0815*
oSearchService = catiaObj.GetSessionService("PLMSearch")
oPLMSearches = oSearchService.Searches
oPLMSearch = oPLMSearches.Add()
oPLMSearch.Type = "PLMProductDS"
# Iterate over all found objects and put them into the turntable view
o3DShapeAsPLMEntities = oPLMSearch.EditedContent
print 'Found %s entries.'%o3DShapeAsPLMEntities.Count
for foundobj in o3DShapeAsPLMEntities:
print 'Putting %s onto the table'%foundobj.Name
oSelection = catiaObj.ActiveEditor.Selection