Switch CATIA windows

One question I’ve been asked several times by readers on my email list is how do you switch CATIA windows? c. Windows is the CATIA object that displays documents in a viewable 2D or 3D form. The Activate method is used to make a window become active and also implies the documents displayed in the active window are also active. catia vb.net

Here’s an example of how it works:

Sub CATMain()

‘set the current document as the active document
Dim Doc
Set Doc = CATIA.ActiveDocument

‘set the current window as the active window
Set WindCol = CATIA.Windows

‘count the number of open windows
Dim DocNum
DocNum = WindCol.Count

‘declare the active window variable
Dim ActWin

‘create a new CATPart
Dim part2
Set part2 = CATIA.Documents.Add(“CATPart”)          

‘rename the new part
part2.Product.PartNumber = “My New Part”
 
‘There are two ways to change the active window: using the index number or by name

‘return the second window in the collection
Set ActWin = CATIA.Windows.Item(2)

‘return the window named “Enovia V6”
‘Set ActWin = CATIA.Windows.item(“ENOVIAV6.CATProduct”)
 
‘activate the window
ActWin.Activate

End Sub

Windows can also be arranged using the Arrange method. To arrange the open windows in a cascade style:

CATIA.Windows.Arrange(catArrangeCascade)

Other Arrange methods include catArrangeTiledHorizontal and catArrangeTiledVertical.

catia vba

A window is an abstract object that falls under the Windows collection. Just to help avoid confusion, the Viewers collection enables the window to display the application data in the desired mode using viewers. The SpecsAndGeomWindow object features a viewer and a specification tree viewer. This enables you to turn the spec tree on and off, like so:

‘turn off the spec tree
Dim oSpecWindow As SpecsAndGeomWindow
Set oSpecWindow = CATIA.ActiveWindow
oSpecWindow.Layout = catWindowGeomOnly

And conversely, to turn the specification tree back on:

‘turn the spec tree back on
objSpecWindow.Layout = catWindowSpecsAndGeom