This is part of a Rule provided by another user to switch the Visibilty of Workplanes:
'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
How should I address other Workfeatures in a similar vein including Axis, Points and Surfaces and not just WorkPlanes?
For under Work Features in System Snippets only two simple options are provided which do not satisfy my requirements.
Applying 'simple logic' I attempted to use the following to address Work Axis to no avail:
For Each oWorkAxis In openDoc.ComponentDefinition.WorkAxis
And received this error:
Public member 'WorkAxis' on type 'AssemblyComponentDefinition' not found.
Thanks.
CJ
It would seem to me that I am unable to turn the workplane visibility (on the assembly level) on or off by setting a work plane’s property of Visible to False. Instead I had to use the Object Visibility (Found commonly on the View tab of Inventor) to change the setting for User Work Plane visibility from there.
Here is my code.
If ThisApplication.ActiveDocument.DocumentType <> Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then MessageBox.Show("Please run this from an Assembly!", "Bad Level Error") Return End If 'Assuming that you have a TRUE / FALSE parameter '(Named - myTrueFalseParameter) 'that is inside of your assembly, you will be 'able to use that as the 'switch' that determines 'the visibility state (ON / OFF) of the workplanes 'on the Assembly level using the below line of code. ThisApplication.ActiveDocument.ObjectVisibility.UserWorkPlanes = myTrueFalseParameter ThisApplication.ActiveDocument.ObjectVisibility.UserWorkAxes = myTrueFalseParameter ThisApplication.ActiveDocument.ObjectVisibility.UserWorkPoints = myTrueFalseParameter
Remember to set up your true / false parameter inside of your assembly document if you want this to work.
You should probably also read the following post over on Inventor Trenches (wonderful blog)
http://inventortrenches.blogspot.com/2013/03/turn-onoff-all-workfeatures-with-ilogic.html
Hi MegaJerk,
Thank you so much, I will check your solution and suggested link out tonight and get back to you.
In the meantime thank you for your kind assistance.
CJ