I'm trying to get a rule working for setting the assembly level work feature visibility states on/off, this is not the same as the "Object Visibility" function in the view tab that I'm looking for, which just overrides any visibility states set in the browser.
I have a rule that sets the visibility states at part level, which works great, but if I set visibility for a work plane for instance in the top level assembly, the part level rule will not affect it, so as far as I can tell the assembly level visibility setting overrules the part level one (this is due to view rep?). I'm trying to modify the part level rule, and this is what I have so far;
SyntaxEditor Code Snippet
'catch and skip errors On Error Resume Next 'define the active assembly Dim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument 'Set as False to hide wfBoolean = False 'set workplane dimensions visibility For Each oWorkPlane In oAssyDoc.ComponentDefinition.WorkPlanes oWorkPlane.Visible = wfBoolean Next 'update the files InventorVb.DocumentUpdate()
This code however, does not do anything as far as I can tell, how do I make this work on the assembly level to hide/show work features?
I found some code and altered it to try to make it do what I want, and this is it:
SyntaxEditor Code Snippet
' 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 = "iLogicRep" '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 'toggle work features in the open document (top level assembly) For Each oWorkPlane In openDoc.ComponentDefinition.WorkPlanes oWorkPlane.Visible = False Next iLogicVb.UpdateWhenDone = True
This works like I'm wanting it to, but it only changes the state of the origin planes and work planes that are on root level in the assembly. The rule does not target work planes that belong to components and have been set to visible on the assembly level. I want all the work planes found in the assembly browser tree to be switched by the rule.