Hi @andrew_wade1. This task has been a relatively popular one on this forum over the years, so if you used the search functionality of this forum, you will likely see lots of other conversations about it, and lots of other example codes you could try out. Many of them only turn off work features, such as WorkPoints, WorkAxes, and WorkPlanes, but some also work with other types of things. Below is an example iLogic rule you can try out for a task like that.
However, this can be a relatively complex task, with lots of different aspects and details involved, each of which may cause this task to not work exactly as planned. Visibility settings are saved within the DesignViewRepresentations that are within the RepresentationsManager of the ComponentDefinition, within each document. Then, every individual assembly component occurrence can each have their DVR (DesignViewRepresentation) set differently, which potentially means different appearances or visibility settings. If you are not using all the DVR settings along the way in each document and in each occurrence, then this may not work properly for you.
Sub Main
Dim oDoc As Inventor.Document = ThisDoc.Document
Dim oTrans As Inventor.Transaction
oTrans = ThisApplication.TransactionManager.StartTransaction(oDoc, "Set Visibility - iLogic")
SetVisibility(oDoc, False)
Dim oRefDocs As DocumentsEnumerator = oDoc.AllReferencedDocuments
For Each oRefDoc As Inventor.Document In oRefDocs
SetVisibility(oRefDoc, False)
Next oRefDoc
oDoc.Update2(True)'do not use 'If oDoc.RequiresUpdate', it will be False
oTrans.End
'If oDoc.Dirty Then oDoc.Save2(True)
End Sub
Sub SetVisibility(oDoc As Document, bVisible As Boolean)
If oDoc Is Nothing OrElse oDoc.IsModifiable = False Then Return
If (Not TypeOf oDoc Is AssemblyDocument) AndAlso (Not TypeOf oDoc Is PartDocument) Then Return
Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
For Each oWA As WorkAxis In oCD.WorkAxes
If oWA.Visible <> bVisible Then oWA.Visible = bVisible
Next
For Each oWP As WorkPlane In oCD.WorkPlanes
If oWP.Visible <> bVisible Then oWP.Visible = bVisible
Next
For Each oWPt As WorkPoint In oCD.WorkPoints
If oWPt.Visible <> bVisible Then oWPt.Visible = bVisible
Next
Try 'assemblies do not have these, only parts
For Each oWS As WorkSurface In oCD.WorkSurfaces
If oWS.Visible <> bVisible Then oWS.Visible = bVisible
Next
Catch : End Try
For Each oSketch As PlanarSketch In oCD.Sketches
If oSketch.Visible <> bVisible Then oSketch.Visible = bVisible
Next
Try 'assemblies do not have these, only parts
For Each o3DSketch As Sketch3D In oCD.Sketches3D
If o3DSketch.Visible <> bVisible Then o3DSketch.Visible = bVisible
Next
Catch : End Try
For Each oMA As ModelAnnotation In oCD.ModelAnnotations
If oMA.Visible <> bVisible Then oMA.Visible = bVisible
Next
'oDoc.Update2(True)
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)