I am also trying to hide all workplanes in an assembly and am having trouble getting it to work. I have tried three methods found in various threads to no avail. They are:
1) Going directly to the occurrence in the assembly and turning the workplanes off. (assumes all parts in assembly are sub assemblies)
Dim oPlane As WorkPlane
Dim oPlanes As WorkPlanes
Dim oOccurrences As ComponentOccurrences
Dim oOccurrence As ComponentOccurrence
Dim oAssyCompDef As AssemblyComponentDefinition
Dim oSubAssyCompDef As AssemblyComponentDefinition
Set oOccurrences = oAssyCompDef.Occurrences
For Each oOccurrence In oOccurrences
Set oSubAssyCompDef = oOccurrence.Definition
Set oPlanes = oSubAssyCompDef.WorkPlanes
For Each oPlane In oPlanes
oPlane.Visible = False
Next
Next
2) Creating proxies of the workplanes with respect to the top level assembly and turning their visibility off.
Dim oPlane As WorkPlane
Dim oPlaneProxy As WorkPlaneProxy
Dim oPlanes As WorkPlanes
Dim oOccurrences As ComponentOccurrences
Dim oOccurrence As ComponentOccurrence
Dim oAssyCompDef As AssemblyComponentDefinition
Dim oSubAssyCompDef As AssemblyComponentDefinition
Set oOccurrences = oAssyCompDef.Occurrences
For Each oOccurrence In oOccurrences
Set oSubAssyCompDef = oOccurrence.Definition
Set oPlanes = oSubAssyCompDef.WorkPlanes
For Each oPlane In oPlanes
Call oOccurrence.CreateGeometryProxy(oPlane, oPlaneProxy)
oPlaneProxy.Visible = False
Next
Next
3) Using "AppAllWorkFeaturesCmd" control definition (Sanjay's code)
'Get the "Object Visibility -> All Workfeatures" command
Dim oCtrlDef As ButtonDefinition
Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppAllWorkfeaturesCmd")
'Check whether the option is checked. If it is, uncheck it.
If oCtrlDef.Pressed Then
MsgBox "Pressed"
oCtrlDef.Execute
End If
I cannot get any of these to turn off a plane in a subassembly that I don't want. The workplane is in a subassembly which is at the top level of the main assembly.
Main Assembly
-SubAssembly1
--Offending WorkPlane
-SubAssembly 2
...
What am I doing wrong here?
____________________________
Inventor Professional 2014 64 Bit
Windows 7 Professional
NVIDIA Quadro FX 4600
Dual Intel Xeon E5540 CPUs
16GB DDR3 Ram