<?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 Switch off part visibility in sub-assembly in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/switch-off-part-visibility-in-sub-assembly/m-p/10700500#M130313</link>
    <description>&lt;P&gt;I have an assembly 'A' with a lot of sub-assemblies.&lt;/P&gt;&lt;P&gt;One of these is 'Subassembly B'. The quantity of&amp;nbsp;'Subassembly B' in 'Assembly A' is variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In&amp;nbsp;'Subassembly B', I need to switch on/off the visibility of 'Part 1' according to user input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have already made a form for the user input.&lt;/P&gt;&lt;P&gt;Part 1 required?: Yes/no&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I switch off visibility of all occurrences of 'Part 1'?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Oct 2021 09:01:02 GMT</pubDate>
    <dc:creator>sheetal.b</dc:creator>
    <dc:date>2021-10-20T09:01:02Z</dc:date>
    <item>
      <title>Switch off part visibility in sub-assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/switch-off-part-visibility-in-sub-assembly/m-p/10700500#M130313</link>
      <description>&lt;P&gt;I have an assembly 'A' with a lot of sub-assemblies.&lt;/P&gt;&lt;P&gt;One of these is 'Subassembly B'. The quantity of&amp;nbsp;'Subassembly B' in 'Assembly A' is variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In&amp;nbsp;'Subassembly B', I need to switch on/off the visibility of 'Part 1' according to user input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have already made a form for the user input.&lt;/P&gt;&lt;P&gt;Part 1 required?: Yes/no&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I switch off visibility of all occurrences of 'Part 1'?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 09:01:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/switch-off-part-visibility-in-sub-assembly/m-p/10700500#M130313</guid>
      <dc:creator>sheetal.b</dc:creator>
      <dc:date>2021-10-20T09:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Switch off part visibility in sub-assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/switch-off-part-visibility-in-sub-assembly/m-p/10700889#M130316</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11358595"&gt;@sheetal.b&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The trick to find all these occurrences is to use Occurrences.AllReferencedOccurrences in your main assembly.&lt;/P&gt;
&lt;P&gt;All you need is a document-object for your 'Part 1'. Here's an example, assuming the subassembly occurrences are named 'Subassembly B:1', 'Subassembly B:2', 'Subassembly B:3' and so on. And the 'Part1'-occurrence in the subassembly is named 'Part1:1'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN style="color: #ce5c95;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;oAsm&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;AssemblyDocument&lt;/SPAN&gt; = &lt;SPAN style="color: #9d6bce;"&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN style="color: #9d6bce;"&gt;Document&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;oDef&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;AssemblyComponentDefinition&lt;/SPAN&gt; = &lt;SPAN style="color: #db9652;"&gt;oAsm&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;ComponentDefinition&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;subAsm&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;AssemblyDocument&lt;/SPAN&gt; = &lt;SPAN style="color: #db9652;"&gt;oDef&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;Occurrences&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;ItemByName&lt;/SPAN&gt;(&lt;SPAN style="color: #35b173;"&gt;"Subassembly B:1"&lt;/SPAN&gt;).&lt;SPAN style="color: #db9652;"&gt;Definition&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;Document&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;part1&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN style="color: #db9652;"&gt;subAsm&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;ComponentDefinition&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;Occurrences&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;ItemByName&lt;/SPAN&gt;(&lt;SPAN style="color: #35b173;"&gt;"Part1:1"&lt;/SPAN&gt;).&lt;SPAN style="color: #db9652;"&gt;Definition&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;Document&lt;/SPAN&gt;

&lt;SPAN style="color: #ce5c95;"&gt;For&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;Each&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;oOcc&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;ComponentOccurrence&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;In&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;oDef&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;Occurrences&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;AllReferencedOccurrences&lt;/SPAN&gt;(&lt;SPAN style="color: #db9652;"&gt;part1&lt;/SPAN&gt;)
	&lt;SPAN style="color: #db9652;"&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;Visible&lt;/SPAN&gt; = &lt;SPAN style="color: #ce5c95;"&gt;False&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;Next&lt;/SPAN&gt;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Oct 2021 11:48:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/switch-off-part-visibility-in-sub-assembly/m-p/10700889#M130316</guid>
      <dc:creator>JhoelForshav</dc:creator>
      <dc:date>2021-10-20T11:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Switch off part visibility in sub-assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/switch-off-part-visibility-in-sub-assembly/m-p/10700976#M130319</link>
      <description>&lt;P&gt;Try this code&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim oDoc As AssemblyDocument =  ThisDoc.Document
Dim subAssembly As AssemblyDocument

'here declare your names - subassembly and part to hide
Dim subAssemblyName As String = "Subassembly B"
Dim subPartName As String = "Part 1"
Dim hide As Boolean = True 'this must be connected with your form 
'maybe create a boolean parameter and put it in your form, 
'then you can replace this "true" with your parameter value

For Each subOcc As ComponentOccurrence In oDoc.ComponentDefinition.Occurrences
	If subOcc.Name.Contains(subAssemblyName) Then
		subAssembly = subOcc.Definition.Document
	Exit for
	End If
Next
If subAssembly Is Nothing Then Return

For Each oOcu As ComponentOccurrence In subAssembly.ComponentDefinition.Occurrences
		If oOcu.Name.Contains(subPartName) Then
			If hide=True Then
			oOcu.Visible = False
				Else
			oOcu.Visible = True
			End If
			Else
			oOcu.Visible = True
		End If
			
	Next&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 12:17:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/switch-off-part-visibility-in-sub-assembly/m-p/10700976#M130319</guid>
      <dc:creator>TomaszDąbrowski</dc:creator>
      <dc:date>2021-10-20T12:17:10Z</dc:date>
    </item>
  </channel>
</rss>

