How to search CATIA V6 macro

To search in CATIA using a macro, the format is “search criteria, search range.” To search for the name pad in an entire document in CATIA V5 using a macro, you would use this code:

Dim oSel As Selection

Set oSel = CATIA.ActiveDocument.Selection

oSel.Search “Name=Pad*,all”

To search for a name in an entire document in 3DX, use this:

Dim oSel As Selection

Set oSel = CATIA.ActiveEditor.Selection

oSel.Search “Name=Pad*,all”

To search for a part or product in the active object in V5, use this:

Dim oSel As Selection

Set oSel = CATIA.ActiveDocument.Selection

oSel.Search “(Type=Part + Product),in”

To search for a part or product in the active document in 3Dexperience, use this code:

Dim oSel As Selection

Set oSel = CATIA.ActiveEditor.Selection

oSel.Search “(Type=’Physical Representation’ + ‘Physical Product’),in”

To search for the display status of annotation text under an active object in CATIA V5:

Dim oSel As Selection

Set oSel = CATIA.ActiveDocument.Selection

oSel.Search “CATTPSearch.CATTPSText.Visibility = Visible, from”

To do the same in V6:

Dim oSel As Selection

Set oSel = CATIA.ActiveEditor.Selection

oSel.Search “‘3D Tolerancing & Annotation’, ‘Annotation’.Visibility = Visible, from”

To search for visible parts in the selected range in V5:

Dim oSel As Selection

Set oSel = CATIA.ActiveDocument.Selection

oSel.Search “CATGmoSearch.PartFeature, sel”

In V6:

Dim oSel As Selection

Set oSel = CATIA.ActiveEditor.Selection

oSel.Search “‘Product Structure’,’Physical Representation’,sel”

If you don’t know the object type for the search condition, refer to the Find dialog box. Count the items with Selection.Count and extract the result with Selection.Item(i).Value

If you want to learn more V6 macros let us know in the comments below!

Add a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.