Hi @Inventor_Enjoyer. I assume you mean for the code to only effect the top level sub assemblies, and not any sub assemblies that are deeper than that, is this correct? If so, then I have some iLogic code below that I think may work for you.
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oOccs As ComponentOccurrences = oADef.Occurrences
For Each oOcc As ComponentOccurrence In oOccs
If oOcc.Suppressed Then Continue For
If TypeOf oOcc.Definition Is VirtualComponentDefinition Then Continue For
If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
Dim oSubADef As AssemblyComponentDefinition = oOcc.Definition
Dim oSubAsmBOM As BOM = oSubADef.BOM
If Not oSubAsmBOM.StructuredViewEnabled Then
oSubAsmBOM.StructuredViewEnabled = True
End If
End If
Next
If oADoc.RequiresUpdate Then oADoc.Update2(True)
If oADoc.Dirty Then oADoc.Save2
But if you need it to effect all sub-assemblies in every level of the assembly, then this code may need to be changed a bit. It wouldn't be that difficult to do though. Instead of iterating through components, we could iterate through 'AllReferencedDocuments' to do that.
Wesley Crihfield

(Not an Autodesk Employee)