Is there a way to automate the process of turning off the Workfeatures in a .iam and STILL be able to add new Workfeatures. View>Object Visibility is not the answer because you are unable to construct NEW Workfeatures. If there isn’t a menu selection, can a “batch file” be developed to search the Browser and turn off all Workfeatures currently listed in the tree?
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
The following VB code will turn off all work planes, axis and points currently visible in the drawing whether they are user created or the default origin planes. Place this code inside a module of a VB project and run it from there. I use this all the time and it has worked great for me. There is also a slightly modified version below that could be run using iLogic as well.
Public Sub TurnOffWorkFeatures()
Set Drawing = ThisApplication.ActiveDocument
For Each wp In Drawing.ComponentDefinition.WorkPlanes
wp.Visible = False
Next
For Each wa In Drawing.ComponentDefinition.WorkAxes
wa.Visible = False
Next
For Each wt In Drawing.ComponentDefinition.WorkPoints
wt.Visible = False
Next
End Sub
-----------------------------------------------------------------------
iLogic Rule Version
-----------------------------------------------------------------------
Drawing = ThisApplication.ActiveDocument
For Each wp In Drawing.ComponentDefinition.WorkPlanes
wp.Visible = False
Next
For Each wa In Drawing.ComponentDefinition.WorkAxes
wa.Visible = False
Next
For Each wt In Drawing.ComponentDefinition.WorkPoints
wt.Visible = False
Next
Hi crash_dummy,
As coreyparks mentioned you can use an iLogic rule to do this. Below is another code snippet variation that you can paste into a new iLogic rule. This iLogic rule looks at all of the workplanes in the assembly and it's components. It will work if you run it on part files also.
If you've not created a rule before, here are a couple of links to help:
http://inventortrenches.blogspot.com/2012/01/creating-basic-ilogic-rule-with-event.html
http://autodeskmfg.typepad.com/blog/2012/01/working-with-external-ilogic-rules.html
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
'Look at all of the files referenced in the open document
Dim docFile As 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 oWorkPlane.Visible = True Then
oWorkPlane.Visible = False
ElseIf oWorkPlane.Visible = False Then
oWorkPlane.Visible = True
End If
Next
Next
'look at the workplane collection in the assembly
For Each oWorkPlane In openDoc.ComponentDefinition.WorkPlanes
'toggle all work planes
If oWorkPlane.Visible = True Then
oWorkPlane.Visible = False
ElseIf oWorkPlane.Visible = False Then
oWorkPlane.Visible = True
End If
Next
iLogicVb.UpdateWhenDone = True
Hi! I am not sure if you are familiar with Design View. When a component is placed in an assembly, the Design View is set to Master by default. That is why you see all the work features (or objects) show up. In a component (a part or an assembly), you can create a Design View with all existing work planes invisible. Then any newly created work planes will remain visible until you make them invisible.
In the top level assembly, you can simply right-click on any component (containin a non-Master DV) -> Representation -> set it to the desirable DV. Could you try it and see how it works?
Thanks!
Best bet is good modeling practices and turn off uneeded planes, sketches, etc as you make the parts so once the assembly is done it is clean and clear of clutter.
Agreed, but until they fix it so any turned off manually stay off until turned back on... I go thru that here as well, as like you said not everyone follows good practices and its quite aggrevating to have 300 workplanes blocking your view and adding new ones becomes almost impossible as you can't see anything. Time for a drafting meeting 🙂
This is the reason I never turn work planes on and off for parts while inside of the assembly. If I need to see a work plane for a part I open the part and turn it on and off there so they don't appear again later, which is what the code I had posted was for. The code will only turn off a work plane if you are inside of the file where it was created. We created this due to one user we had that turned on every work plane in every part in every assembly that he worked on as he liked to work this way, it made all of the preview icons worthless.
Hi crash_dummy,
Here is an updated iLogic rule that will reach down into each subassembly and turn On/Off all workfeatures.
http://inventortrenches.blogspot.com/2013/03/turn-onoff-all-workfeatures-with-ilogic.html
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
On Error Resume Next
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument
Dim oDoc As Inventor.Document
'get user input as True or False
wfBoolean = InputRadioBox("Turn all Work Features On/Off", "On", "Off", False, "iLogic")
'Check all referenced docs
For Each oDoc In oAssyDoc.AllReferencedDocuments
'set work plane visibility
For Each oWorkPlane In oDoc.ComponentDefinition.WorkPlanes
oWorkPlane.Visible = wfBoolean
Next
'set work axis visibility
For Each oWorkAxis In oDoc.ComponentDefinition.WorkAxes
oWorkAxis.Visible = wfBoolean
Next
'set work point visibility
For Each oWorkPoint In oDoc.ComponentDefinition.WorkPoints
oWorkPoint.Visible = wfBoolean
Next
Next
InventorVb.DocumentUpdate()