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.
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.
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
Hello there!
I usually work with projects that have multiple catdrawing sheets, and whenever I have to compare multiple sheets (old sheet 1 vs new sheet 1, old sheet 2 vs new sheet 2 etc) it’s a huge pain because the tile windows functions won’t let me choose the windows I want to tile (we can do this in windows 7 already via task manager). Is there a way to implement this via VBA?
I was thinking about prompting a form with all the open windows, so we can choose 2 or more to tile, this way will be much easier to compare multiple sheets.