Ok try it on a part that is not read only . Select part and press esc this cancels the loop and allows to work on the part selected. It is possible read only parts were selected . I selected a read only part below and it errored out

To get around the read only file error you can place an On error resume next which will move on to the next file if an error occurs. It would be better to check the status of the file if read only or not but this can be difficult to achieve.
Dim comps As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
While True
Dim comp As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a component")
If IsNothing(comp) Then Exit While
comps.Add(comp)
End While
On Error Resume Next
For Each comp In comps
Dim WP As WorkPlane = comp.definition.document.ComponentDefinition.WorkPlanes.Item(1)
Dim oValue As Boolean
If WP.Visible = True Then oValue = False Else oValue = True
For i As Integer = 1 To 3
comp.definition.document.ComponentDefinition.WorkPlanes.Item(i).Visible = oValue
Next
iLogicVb.UpdateWhenDone = True
Next
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan