CATIA Macro to Open in New Window

Often times when you’re working in a large assembly in CATIA V5 you want to look at a single part or subsystem and the easiest way to do that is right click on the part or product in the specification tree and click “Open in New Window.” But what if you want to use a CATIA macro to open in new window? The easiest way is to use StartCommand method:

CATIA.StartCommand “Open in New Window”

To open a selection in a new window, try this:

If UserSelection = “Normal” Then

CATIA.StartCommand “Open in New Window”

Else

‘Take some other action…

End If

As long as an instance is selected, this command will open the part in its own window. I added a check to be sure the selection was successful before calling because if nothing is selected CATIA just ignores the command plus you might want to do another action anyways, like close the program.

Not everyone likes using StartCommand method. You could use Use NewWindow method:

CATIA.Documents.Item(“MyPart.CATPart”).NewWindow()

However, it appears NewWindow is either broken or behaves erratically, therefore I usually stick to the StartCommand way.

Here’s an example using SelectElement2 where we will ask the user to select a CATProduct from the tree and the macro will open that product in a new window. Notice the error handling in case there is a problem with the user’s selection.

 

Add a Comment

Your email address will not be published. Required fields are marked *