<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Ilogic Rule to find all Reference parts and turn off visibilty in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/5933020#M130129</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/516632"&gt;@cwhetten&lt;/a&gt; wrote:&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Instead, the approach I chose to use only overrides the visibility at the main assembly level.&amp;nbsp; I think this approach will be appropriate for most situations.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So, why is it so hard to automate something that we can do manually?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We often have vehicle frame components&amp;nbsp;that show up in several subassembly levels&amp;nbsp;as reference parts. But if I want to constrain a part to the frame at the top level, I don't know which of the dozen or more&amp;nbsp;instances of the frame to attach it to except by trial and error.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Dec 2015 17:11:47 GMT</pubDate>
    <dc:creator>lesmfunk</dc:creator>
    <dc:date>2015-12-02T17:11:47Z</dc:date>
    <item>
      <title>Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4305340#M130120</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I there a way of finding each Bom structured part that is set to reference in an assembly and setting the view of that component to in-visible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also needs to iterate into all set View reps that where created and set all views to not show the referenced parts as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thought or code snippets would be appreciated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2013 06:37:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4305340#M130120</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-06-21T06:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4306025#M130121</link>
      <description>&lt;P&gt;Here's a start:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;oCompDef = ThisDoc.Document.ComponentDefinition&lt;BR /&gt;oAssemblyComponents = oCompDef.Occurrences&lt;BR /&gt;oViewRepsCollection = oCompDef.RepresentationsManager.DesignViewRepresentations&lt;BR /&gt;oActiveViewRep = oCompDef.RepresentationsManager.ActiveDesignViewRepresentation&lt;BR /&gt;&lt;BR /&gt;Dim oOccurrence As ComponentOccurrence&lt;BR /&gt;Dim oViewRep As DesignViewRepresentation&lt;BR /&gt;&lt;BR /&gt;For Each oViewRep In oViewRepsCollection&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;oViewRep.Activate 'Activate each view rep one at a time&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;For Each oOccurrence In oAssemblyComponents&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If (oOccurrence.BOMStructure = BOMStructureEnum.kReferenceBOMStructure) Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;oOccurrence.Visible = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;oOccurrence.Visible = True&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Next&lt;BR /&gt;Next&lt;BR /&gt;&lt;BR /&gt;oActiveViewRep.Activate 'Sets the view rep back to the one that was active before the rule was executed&lt;/PRE&gt;&lt;P&gt;A couple of caveats:&lt;/P&gt;&lt;P&gt;This code only checks the BOM structure and sets the visibility of components in the first level of the assembly.&amp;nbsp; If you have sub-assemblies with reference components, it won't change their visibility.&amp;nbsp; The code could be expanded to do this, but I didn't want to do that yet in case this is all you need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If any of your view representations are locked, this code will not work at all.&amp;nbsp; If your design has some that are locked, we will have to change the code to have it skip any locked view reps (or unlock them, change them, then re-lock them).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also made it so that it would switch back to whatever view rep was active before you executed the rule.&amp;nbsp; This isn't necessary, but it may be convenient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cameron Whetten&lt;BR /&gt;Inventor 2012&lt;BR /&gt;&lt;IMG border="0" height="20%" width="20%" src="http://download.autodesk.com/us/expert_elite/ADSK_Expert_Elite_Icon_S_Color_Blk.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966"&gt;Please click "Accept as Solution" if this response answers your question.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2013 17:48:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4306025#M130121</guid>
      <dc:creator>cwhetten</dc:creator>
      <dc:date>2013-06-21T17:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4306584#M130122</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;cwhetton&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help on this firstly few comments on what we are trying to achieve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;We have locked view reps which will need to be updated (so code would need to iterate into all view reps and lock them back down.&lt;/LI&gt;&lt;LI&gt;We would also need to run this code down to all levels sub-assemblies etc.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;When I inserted code into ilgic rule there was 3 errors and would not run attached is screen grab of code errors&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff6600"&gt;Rule Compile Errors in Rule1, in CAM-01-0425-000.iam&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff6600"&gt;Error on Line 3 : End of statement expected.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff6600"&gt;Error on Line 4 : End of statement expected.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff6600"&gt;Error on Line 20 : 'oActiveViewRep' is not declared. It may be inaccessible due to its protection level.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I&amp;nbsp;appreciate your help on this&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2013 14:10:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4306584#M130122</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-06-22T14:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4307704#M130123</link>
      <description>&lt;P&gt;I'm not sure why this isn't working for you.&amp;nbsp; I don't get those errors.&amp;nbsp; Maybe something weird happened when you copied and pasted from the message board?&amp;nbsp; Also, for the record, which version of Inventor are you using?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Getting the code to run through the locked view reps should be pretty easy, but it's going to be a little more involved to get it to iterate through all levels of the assembly.&amp;nbsp; I will have to give this one some more thought.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cameron Whetten&lt;BR /&gt;Inventor 2012&lt;BR /&gt;&lt;IMG border="0" height="20%" width="20%" src="http://download.autodesk.com/us/expert_elite/ADSK_Expert_Elite_Icon_S_Color_Blk.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2013 16:23:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4307704#M130123</guid>
      <dc:creator>cwhetten</dc:creator>
      <dc:date>2013-06-24T16:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4307727#M130124</link>
      <description>Copy the code into a text file first, and make sure it matches what Cameron posted perfectly. Look for any funky characters or line breaks in the wrong spot. There's frequently problems like this when you copy/paste from this board.</description>
      <pubDate>Mon, 24 Jun 2013 16:48:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4307727#M130124</guid>
      <dc:creator>mrattray</dc:creator>
      <dc:date>2013-06-24T16:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4308012#M130125</link>
      <description>HI cwhetton&lt;BR /&gt;&lt;BR /&gt;Got it to work pasted it into word and pasted it from there and it worked.&lt;BR /&gt;I use Autodesk Product Design Suite Standard 2013 with sp2 installed.&lt;BR /&gt;&lt;BR /&gt;It errors if master is active at time of running code ,I assume that is because it is a locked viewrep as default.&lt;BR /&gt;&lt;BR /&gt;Thanks for looking at the code to look down all levels as this would be perfect for me , that in conjunction with viewreps nlock and re-lock would be cherry on the cake.&lt;BR /&gt;&lt;BR /&gt;Just one more thing is it possible to return the viewrep to default at end instead of active view rep.&lt;BR /&gt;&lt;BR /&gt;cheers&lt;BR /&gt;&lt;BR /&gt;dc</description>
      <pubDate>Mon, 24 Jun 2013 20:54:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4308012#M130125</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-06-24T20:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4308845#M130126</link>
      <description>&lt;P&gt;Just letting you know I haven't forgotten about this.&amp;nbsp; I am still trying to figure out how to make it cycle through all subassemblies.&amp;nbsp; It has proven to be quite the challenge for me.&amp;nbsp; I'll keep you posted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cameron Whetten&lt;BR /&gt;Inventor 2012&lt;BR /&gt;&lt;IMG height="20%" border="0" width="20%" src="http://download.autodesk.com/us/expert_elite/ADSK_Expert_Elite_Icon_S_Color_Blk.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2013 16:34:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4308845#M130126</guid>
      <dc:creator>cwhetten</dc:creator>
      <dc:date>2013-06-25T16:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4309007#M130127</link>
      <description>&lt;P&gt;Ok, here is what I have so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-SPOILER&gt;Sub Main()&lt;BR /&gt;&lt;BR /&gt;oCompDef = ThisDoc.Document.ComponentDefinition&lt;BR /&gt;oAssyOccurrences = oCompDef.Occurrences&lt;BR /&gt;oViewRepsCollection = oCompDef.RepresentationsManager.DesignViewRepresentations&lt;BR /&gt;&lt;BR /&gt;Dim oOccurrence As ComponentOccurrence&lt;BR /&gt;Dim oViewRep As DesignViewRepresentation&lt;BR /&gt;Dim oSubOccurrence1 As ComponentOccurrence 'For first level of sub-occurrences&lt;BR /&gt;Dim oSubOccurrence2 As ComponentOccurrence 'For second level of sub-occurrences&lt;BR /&gt;&lt;BR /&gt;For Each oViewRep In oViewRepsCollection&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;oViewRep.Activate 'Activate each view rep one at a time&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If oViewRep.Name = "Master" Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'Do nothing.&amp;nbsp; This makes the code ignore the Master view rep&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If oViewRep.Locked Then 'If the view rep is locked, unlock it, make the changes, then lock it again&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;oViewRep.Locked = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;For Each oOccurrence In oAssyOccurrences 'Run the code for top-level occurrences&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If oOccurrence.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'If the occurrence is an assembly, run the code for each of its sub-occurrences&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If oOccurrence.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'If the whole sub-assembly is set to reference, just turn the whole thing off.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'No need to control the visibility of sub-components.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;oOccurrence.Visible = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else 'Run the code for all sub-components&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;For Each oSubOccurrence1 In oOccurrence.SubOccurrences 'Run the code for the first level of sub-components&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If oSubOccurrence1.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'If the occurrence is an assembly, run the code for each of its sub-occurrences&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If oSubOccurrence1.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'If the whole sub-assembly is set to reference, just turn the whole thing off.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'No need to control the visibility of sub-components.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;oSubOccurrence1.Visible = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else 'Run the code for all sub-components&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;For Each oSubOccurrence2 In oSubOccurrence1.SubOccurrences&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'Run the code for the second level of sub-components&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;fVisibilitySwitch(oSubOccurrence2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else 'Run the code if the sub-component is a part document&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;fVisibilitySwitch(oSubOccurrence1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else 'Run the code if the component is a part document&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;fVisibilitySwitch(oOccurrence)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;oViewRep.Locked = True&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else 'Runs the code on the unlocked view reps&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;For Each oOccurrence In oAssyOccurrences 'Run the code for top-level occurrences&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If oOccurrence.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'If the occurrence is an assembly, run the code for each of its sub-occurrences&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If oOccurrence.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'If the whole sub-assembly is set to reference, just turn the whole thing off.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'No need to control the visibility of sub-components.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;oOccurrence.Visible = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else 'Run the code for all sub-components&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;For Each oSubOccurrence1 In oOccurrence.SubOccurrences 'Run the code for the first level of sub-components&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If oSubOccurrence1.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'If the occurrence is an assembly, run the code for each of its sub-occurrences&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If oSubOccurrence1.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'If the whole sub-assembly is set to reference, just turn the whole thing off.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'No need to control the visibility of sub-components.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;oSubOccurrence1.Visible = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else 'Run the code for all sub-components&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;For Each oSubOccurrence2 In oSubOccurrence1.SubOccurrences&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'Run the code for the second level of sub-components&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;fVisibilitySwitch(oSubOccurrence2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else 'Run the code if the sub-component is a part document&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;fVisibilitySwitch(oSubOccurrence1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else 'Run the code if the component is a part document&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;fVisibilitySwitch(oOccurrence)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;BR /&gt;Next&lt;BR /&gt;&lt;BR /&gt;oViewRepsCollection.Item("Default").Activate 'Sets the view rep back to the one called "Default"&lt;BR /&gt;End Sub&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sub fVisibilitySwitch(oOccurrence As ComponentOccurrence)&lt;BR /&gt;'This sub toggles the component visibility based on if its BOM structure&lt;BR /&gt;' is set to reference (visibility = off) or other (visibility = on).&lt;BR /&gt;If (oOccurrence.BOMStructure = BOMStructureEnum.kReferenceBOMStructure) Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;oOccurrence.Visible = False&lt;BR /&gt;Else If oOccurrence.Visible = False Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'Do nothing.&amp;nbsp; This makes sure that if the visiblity is already off,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;' it will stay off.&amp;nbsp; This prevents the code from undoing any visibility&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;' changes that have been made to set up custom view representations.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'This method will not automatically turn the visiblity on if the item's&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;' BOM structure is changed from reference to something else.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'This will have to be done manually.&lt;BR /&gt;Else&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;oOccurrence.Visible = True&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;BR /&gt;&lt;BR /&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also attached the rule as a TXT file, in case you have trouble copying and pasting the code from the message board.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not totally satisfied with the code as it is here.&amp;nbsp; The problem is that it is only written if your assembly components are themselves assemblies, down to two levels below the main assembly.&amp;nbsp; If there are any sub-assemblies below two levels, this code won't go through them component-by-component.&amp;nbsp; It would have to be re-written in order to accommodate further levels.&amp;nbsp; It's not automatically scalable, and I don't like that.&amp;nbsp; Unfortunately, I haven't figured out a better way to do it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My first try was to do something similar to what Curtis Waguespack suggested in this thread:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/Autodesk-Inventor/Automatically-turning-off-Workfeatures/m-p/3816449#M465442" target="_self"&gt;http://forums.autodesk.com/t5/Autodesk-Inventor/Automatically-turning-off-Workfeatures/m-p/3816449#M465442&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That approach is to cycle through each component that is referenced by the assembly.&amp;nbsp; If I understand it correctly, that would find each component no matter where it is in the assembly structure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, it only works if your view representations are all set up to be associative, all the way down to the deepest component.&amp;nbsp; And it would be extra tricky if each of your subassemblies each had mulitple view reps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead, the approach I chose to use only overrides the visibility at the main assembly level.&amp;nbsp; I think this approach will be appropriate for most situations.&amp;nbsp; HOWEVER--If you do have your view representations set to be associative all the way down, the code I posted will break that (overriding the visibility state will remove any view rep associativity), so don't run it.&amp;nbsp; If this is the case, let me know and I will look into doing it another way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cameron Whetten&lt;BR /&gt;Inventor 2012&lt;BR /&gt;&lt;IMG height="20%" border="0" width="20%" src="http://download.autodesk.com/us/expert_elite/ADSK_Expert_Elite_Icon_S_Color_Blk.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2013 19:10:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4309007#M130127</guid>
      <dc:creator>cwhetten</dc:creator>
      <dc:date>2013-06-25T19:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4309301#M130128</link>
      <description>Hi Cameron&lt;BR /&gt;&lt;BR /&gt;That code works a treat does exactly what I need, a lot of work in code to what I expected and well explained.&lt;BR /&gt;&lt;BR /&gt;I am trying to learn to code at the moment so I can do all this good stuff.&lt;BR /&gt;&lt;BR /&gt;Many thanks for your help&lt;BR /&gt;&lt;BR /&gt;D Clunie</description>
      <pubDate>Wed, 26 Jun 2013 03:59:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/4309301#M130128</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-06-26T03:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/5933020#M130129</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/516632"&gt;@cwhetten&lt;/a&gt; wrote:&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Instead, the approach I chose to use only overrides the visibility at the main assembly level.&amp;nbsp; I think this approach will be appropriate for most situations.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So, why is it so hard to automate something that we can do manually?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We often have vehicle frame components&amp;nbsp;that show up in several subassembly levels&amp;nbsp;as reference parts. But if I want to constrain a part to the frame at the top level, I don't know which of the dozen or more&amp;nbsp;instances of the frame to attach it to except by trial and error.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 17:11:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/5933020#M130129</guid>
      <dc:creator>lesmfunk</dc:creator>
      <dc:date>2015-12-02T17:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/7224719#M130130</link>
      <description>&lt;P&gt;Hello together,&lt;/P&gt;
&lt;P&gt;Hello &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/516632"&gt;@cwhetten&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main()

oCompDef = ThisDoc.Document.ComponentDefinition
oAssyOccurrences = oCompDef.Occurrences
oViewRepsCollection = oCompDef.RepresentationsManager.DesignViewRepresentations

Dim oOccurrence As ComponentOccurrence
Dim oViewRep As DesignViewRepresentation
Dim oSubOccurrence1 As ComponentOccurrence 'For first level of sub-occurrences
Dim oSubOccurrence2 As ComponentOccurrence 'For second level of sub-occurrences

For Each oViewRep In oViewRepsCollection
    oViewRep.Activate 'Activate each view rep one at a time
    If oViewRep.Name = "Master" Then
    'Do nothing.  This makes the code ignore the Master view rep
    Else
        If oViewRep.Locked Then 'If the view rep is locked, unlock it, make the changes, then lock it again
            oViewRep.Locked = False
            For Each oOccurrence In oAssyOccurrences 'Run the code for top-level occurrences
                If oOccurrence.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                'If the occurrence is an assembly, run the code for each of its sub-occurrences
                    If oOccurrence.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then
                    'If the whole sub-assembly is set to reference, just turn the whole thing off.
                    'No need to control the visibility of sub-components.
                        oOccurrence.Visible = False
                    Else 'Run the code for all sub-components
                        For Each oSubOccurrence1 In oOccurrence.SubOccurrences 'Run the code for the first level of sub-components
                            If oSubOccurrence1.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                            'If the occurrence is an assembly, run the code for each of its sub-occurrences
                                If oSubOccurrence1.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then
                                'If the whole sub-assembly is set to reference, just turn the whole thing off.
                                'No need to control the visibility of sub-components.
                                    oSubOccurrence1.Visible = False
                                Else 'Run the code for all sub-components
                                    For Each oSubOccurrence2 In oSubOccurrence1.SubOccurrences
                                    'Run the code for the second level of sub-components
                                        fVisibilitySwitch(oSubOccurrence2)
                                    Next
                                End If
                            Else 'Run the code if the sub-component is a part document
                                fVisibilitySwitch(oSubOccurrence1)
                            End If
                        Next
                    End If
                Else 'Run the code if the component is a part document
                    fVisibilitySwitch(oOccurrence)
                End If
            Next
            oViewRep.Locked = True
        Else 'Runs the code on the unlocked view reps
            For Each oOccurrence In oAssyOccurrences 'Run the code for top-level occurrences
                If oOccurrence.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                'If the occurrence is an assembly, run the code for each of its sub-occurrences
                    If oOccurrence.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then
                    'If the whole sub-assembly is set to reference, just turn the whole thing off.
                    'No need to control the visibility of sub-components.
                        oOccurrence.Visible = False
                    Else 'Run the code for all sub-components
                        For Each oSubOccurrence1 In oOccurrence.SubOccurrences 'Run the code for the first level of sub-components
                            If oSubOccurrence1.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                            'If the occurrence is an assembly, run the code for each of its sub-occurrences
                                If oSubOccurrence1.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then
                                'If the whole sub-assembly is set to reference, just turn the whole thing off.
                                'No need to control the visibility of sub-components.
                                    oSubOccurrence1.Visible = False
                                Else 'Run the code for all sub-components
                                    For Each oSubOccurrence2 In oSubOccurrence1.SubOccurrences
                                    'Run the code for the second level of sub-components
                                        fVisibilitySwitch(oSubOccurrence2)
                                    Next
                                End If
                            Else 'Run the code if the sub-component is a part document
                                fVisibilitySwitch(oSubOccurrence1)
                            End If
                        Next
                    End If
                Else 'Run the code if the component is a part document
                    fVisibilitySwitch(oOccurrence)
                End If
            Next
        End If
    End If
Next

oViewRepsCollection.Item("Default").Activate 'Sets the view rep back to the one called "Default"
End Sub


Sub fVisibilitySwitch(oOccurrence As ComponentOccurrence)
'This sub toggles the component visibility based on if its BOM structure
' is set to reference (visibility = off) or other (visibility = on).
If (oOccurrence.BOMStructure = BOMStructureEnum.kReferenceBOMStructure) Then
    oOccurrence.Visible = False
Else If oOccurrence.Visible = False Then
    'Do nothing.  This makes sure that if the visiblity is already off,
    ' it will stay off.  This prevents the code from undoing any visibility
    ' changes that have been made to set up custom view representations.
    'This method will not automatically turn the visiblity on if the item's
    ' BOM structure is changed from reference to something else.
    'This will have to be done manually.
Else
    oOccurrence.Visible = True
End If

End Sub&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;You can also change the code, the components which are referenced on the color red?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 06:13:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/7224719#M130130</guid>
      <dc:creator>S_May</dc:creator>
      <dc:date>2017-07-13T06:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/12875064#M130131</link>
      <description>&lt;P&gt;I'm having issues running the code. It throws an error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Error on line 18 in rule: hidereference, in document: ASM1029384.iam&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the &lt;STRONG&gt;More Info&lt;/STRONG&gt; tab, there is the following information&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))&lt;BR /&gt;at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&amp;amp; msgData)&lt;BR /&gt;at Inventor.DesignViewRepresentation.set_Locked(Boolean )&lt;BR /&gt;at ThisRule.Main() in rule: hidereference, in document ASM1029384.iam:line 18&lt;BR /&gt;at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)&lt;BR /&gt;at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2024 02:50:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/12875064#M130131</guid>
      <dc:creator>Tayfun_Cetin_FYRPK8J2NTBD</dc:creator>
      <dc:date>2024-07-03T02:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/12875094#M130132</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13447029"&gt;@Tayfun_Cetin_FYRPK8J2NTBD&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which rule did you run?&amp;nbsp; Paste it in the editor here otherwise we don't have the code you used and might have modified. Use the &amp;lt;/&amp;gt; button to keep the format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2024 03:16:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/m-p/12875094#M130132</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2024-07-03T03:16:13Z</dc:date>
    </item>
  </channel>
</rss>

