Do only the parts you want contain "-PLY-", and no other parts names contain that text?
Do you want to search the ComponentOccurrence names (as seen in the Model browser of your main assembly), or do you want to search by their file names? I could also search by their Part Number (in iProperties), if needed.
The following code loops through all ComponentOccurrences within the main assembly, and checks to see if their names contain "-PLY-". If it does, it turns their visibility off.
Try this code:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Assembly Documents.",vbOK, "WRONG DOCUMENT TYPE")
Return
End If
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
For Each oOcc As ComponentOccurrence In oADef.Occurrences
If oOcc.Name.Contains("-PLY-") Then
oOcc.Visible = False
End If
Next
I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.
Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.
- Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
- Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
- Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
- Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
- Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
- SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
- Create DocumentSubTypeEnum Click Here
- Add kRevisionTag or kDrawingRevisionTag to ObjectTypeEnum Click Here
Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)