Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invert selection

Status
Not open for further replies.

PedroOliveira

Student
Feb 19, 2024
1
Invert selection

I have this code in a macro and I wanted your help with something. I want that when executing this line " oGroup.FillSelWithInvert" it does not select the entire inversion of the original selection but rather makes a filter between those that are visible. This way, the selection would be the opposite of the original, but only of the visible parts, not the entire assembly.



Sub CATMain()



Dim selection1 As Selection

Set selection1 = CATIA.ActiveDocument.Selection



If selection1.Count > 0 Then


' Retrieve the Groups collection

Dim cGroups As Object

Set cGroups = CATIA.ActiveDocument.product.GetTechnologicalObject("Groups")


' Create a group with selected products

Dim oGroup As Group

Set oGroup = cGroups.AddFromSel


' Fill the selection with the inverted group

oGroup.FillSelWithInvert


Else

MsgBox "No components selected", vbExclamation, "Isolate Components"

Exit Sub

End If

End Sub
 
Replies continue below

Recommended for you

It might help if we knew what program the macro was for.

If Excel, I find often the easiest way to create a macro is to record it (View-->Macros-->Record Macro). Start the recording, perform the steps you want the macro to do, and then edit as necessary to repeat steps, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor