Since I don't really know yet what you are wanting to do with the faces after they are selected, I'm showing three different processes here that all use the Pick function.
FYI:
- The document's SelectSet is where objects are normally temporarily stored when they are selected manually, or by the SelectSet.Select or SelectSet.SelectMultiple methods in code.
- As far as I know, the document's HighlightSet is purely for visual aid purposes, and is not necessary to use for normal selection purposes when selecting things by code.
- The ObjectCollection is a very handy object used to store all types of objects temporarily in a single variable, so they can either all be acted on at once later, or so they can be looped through later in some other process.
So, depending on your purpose for selecting the faces, you may not need all of these in the following code, but I have included them to show you how to create them and add to them. Here's the new rule:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
'if you have selected anything prior to starting this rule
'those things will be in this document's SelectSet
Dim oSelected As SelectSet = oPDoc.SelectSet
'clearing this set
oSelected.Clear
Dim oFaceCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oHSet As HighlightSet = oPDoc.CreateHighlightSet()
Dim oFace As Face
'the following word is a location marker for the GoTo method below
Repeat :
oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a part face.")
If oFace IsNot Nothing Then
'add the Face to the 'actively selected' set of your document
oSelected.Select(oFace)
'add the Face to an ObjectCollection so you can work with them as a group later
oFaceCollection.Add(oFace)
'add the Face to the document's HighlightSet (visual aid only)
oHSet.AddItem(oFace)
'telling it to go back to where I inserted the word "Repeat", just before the Pick command
'so it will continue to Pick more faces until Nothing is selected
GoTo Repeat
Else
'do nothing, just continue the rule
End If
'now all the Faces you selected are in those sets
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
Wesley Crihfield

(Not an Autodesk Employee)