Hi Diswill,
I think this will do it. I didn't have much time to review this, so you might find some un-needed lines, etc.
I'm probably missing something obvious, but as is this example only looks at sub assemblies one level deep. Meaning that if you have an assembly in your subassembly, it won't turn off the workplanes for the same reasons as before (view reps).
If I think of something different, I'll post back.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
sample #4
'get user input
oInput = InputRadioBox("Select workplane visibility:", _
"Turn ON workplanes for all components", "Turn OFF workplanes for all components", "False", "iLogic")
' set a reference to the assembly component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'Define the open document (top level assembly)
Dim openDoc As Document
openDoc = ThisDoc.Document
'define view rep
Dim oViewRep As DesignViewRepresentation
Dim sVRep as String
'change to something else if Default is used for something already
sVRep = "Default"
'create or activate view rep in the top level assembly
Try
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item(sVRep).Activate
Catch
'create new View Rep
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
End Try
'create or activate view rep in subassemblies
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments
Dim subDoc As AssemblyComponentDefinition
If docFile.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
subDoc = docFile.ComponentDefinition
Try
subDoc.RepresentationsManager.DesignViewRepresentations.Item(sVRep).Activate
Catch
'create new View Rep
subDoc.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
End Try
Else
End If
Next
'toggle work planes in the open document (top level assembly)
For Each oWorkPlane In openDoc.ComponentDefinition.WorkPlanes
'toggle all work planes
If oInput = True Then
oWorkPlane.Visible = True
ElseIf oInput = False Then
oWorkPlane.Visible = False
End If
Next
'look at only the subassemblies
Dim subDocFile As Document
For each oCompOcc in oAsmCompDef.Occurrences
If oCompOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oCompOcc.SetDesignViewRepresentation(sVRep,, True) 'True sets the view rep to be associative
Else
End If
Next
'Look at all of the files referenced in the open document
For Each docFile In openDoc.AllReferencedDocuments
'format file name
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
For Each oWorkPlane In docFile.ComponentDefinition.WorkPlanes
'toggle all work planes
If oInput = True Then
oWorkPlane.Visible = True
ElseIf oInput = False Then
oWorkPlane.Visible = False
End If
Next
Next
iLogicVb.UpdateWhenDone = True
