<?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 - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/re-ilogic-rule-to-find-all-reference-parts-and-turn-off/m-p/10619341#M128822</link>
    <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/45931"&gt;@steveh3&lt;/a&gt;.&amp;nbsp; I'm still using Inv 2021.2.2, so I don't currently have access to ModelStates, but since you only want the code to effect the 'current' view rep / model state, it doesn't seem like a problem to me, as long as they are not 'locked'.&amp;nbsp; I know that design view reps can be locked, and I know that model states have an 'edit member scope' setting to be aware of.&amp;nbsp; I am assuming that if a model state is currently active, it shouldn't be 'out of scope', but the scope may be set to 'all' or 'a specific set', so that is something I'm guessing you would need to keep in mind.&amp;nbsp; I also know that individual components within the assembly can be set to their own representations, and that they can be 'associatively' set to a view rep defined within them.&amp;nbsp; This setting may be a problem when attempting to change the visibility of the component.&amp;nbsp; I don't recall if it throws an error, or just breaks that 'associative' setting automatically to make the visibility change happen.&lt;/P&gt;
&lt;P&gt;Have you tried something simple like this to see if it works?&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;If ThisApplication.ActiveDocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("An Assembly Document must be active for this rule to work. Exiting.",vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
'oVRep = oADef.RepresentationsManager.ActiveDesignViewRepresentation
'oMS = oADef.ModelStates.ActiveModelState
For Each oComp As ComponentOccurrence In oADef.Occurrences
	Try
		If oComp.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then
			'check if this component is associatively set to a view rep defined within itself
			'if so, then changing its visibility may 'break' this setting
			'If oComp.IsAssociativeToDesignViewRepresentation Then
			'	oComp.IsAssociativeToDesignViewRepresentation = False
			'End If
			oComp.Visible = False
		End If
	Catch e As Exception
		MsgBox(e.Message &amp;amp; vbCrLf &amp;amp; e.StackTrace, , "")
	End Try
Next&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Sep 2021 18:12:15 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2021-09-13T18:12:15Z</dc:date>
    <item>
      <title>Re: Ilogic Rule to find all Reference parts and turn off visibilty</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/re-ilogic-rule-to-find-all-reference-parts-and-turn-off/m-p/10619090#M128818</link>
      <description>&lt;P&gt;Hello Gang...almost exactly what I'm looking for.&lt;/P&gt;&lt;P&gt;I want to run same code but just on the active View Rep / Model State.&lt;/P&gt;&lt;P&gt;I messed around with code, but couldn't get it to go.&lt;/P&gt;&lt;P&gt;Possible?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 16:21:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/re-ilogic-rule-to-find-all-reference-parts-and-turn-off/m-p/10619090#M128818</guid>
      <dc:creator>steveh3</dc:creator>
      <dc:date>2021-09-13T16:21:31Z</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-ilogic/re-ilogic-rule-to-find-all-reference-parts-and-turn-off/m-p/10619341#M128822</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/45931"&gt;@steveh3&lt;/a&gt;.&amp;nbsp; I'm still using Inv 2021.2.2, so I don't currently have access to ModelStates, but since you only want the code to effect the 'current' view rep / model state, it doesn't seem like a problem to me, as long as they are not 'locked'.&amp;nbsp; I know that design view reps can be locked, and I know that model states have an 'edit member scope' setting to be aware of.&amp;nbsp; I am assuming that if a model state is currently active, it shouldn't be 'out of scope', but the scope may be set to 'all' or 'a specific set', so that is something I'm guessing you would need to keep in mind.&amp;nbsp; I also know that individual components within the assembly can be set to their own representations, and that they can be 'associatively' set to a view rep defined within them.&amp;nbsp; This setting may be a problem when attempting to change the visibility of the component.&amp;nbsp; I don't recall if it throws an error, or just breaks that 'associative' setting automatically to make the visibility change happen.&lt;/P&gt;
&lt;P&gt;Have you tried something simple like this to see if it works?&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;If ThisApplication.ActiveDocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("An Assembly Document must be active for this rule to work. Exiting.",vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
'oVRep = oADef.RepresentationsManager.ActiveDesignViewRepresentation
'oMS = oADef.ModelStates.ActiveModelState
For Each oComp As ComponentOccurrence In oADef.Occurrences
	Try
		If oComp.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then
			'check if this component is associatively set to a view rep defined within itself
			'if so, then changing its visibility may 'break' this setting
			'If oComp.IsAssociativeToDesignViewRepresentation Then
			'	oComp.IsAssociativeToDesignViewRepresentation = False
			'End If
			oComp.Visible = False
		End If
	Catch e As Exception
		MsgBox(e.Message &amp;amp; vbCrLf &amp;amp; e.StackTrace, , "")
	End Try
Next&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 18:12:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/re-ilogic-rule-to-find-all-reference-parts-and-turn-off/m-p/10619341#M128822</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-09-13T18:12:15Z</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-ilogic/re-ilogic-rule-to-find-all-reference-parts-and-turn-off/m-p/10622486#M128879</link>
      <description>&lt;P&gt;Gang...&lt;/P&gt;&lt;P&gt;Thanks for all the insight. So here's where I ended up and will share the logic....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Creates new View Rep and turns off all reference components at that level. Then activates the original View Rep when the iLogic was initiated....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;' Creates a new View Rep "Active Components" and then turns all Reference Components visibility to off.&lt;/SPAN&gt;
&lt;SPAN&gt;'It only turns On active Components at this level.&lt;/SPAN&gt;
&lt;SPAN&gt;'Then returns back to original active View Rep when logic was initiated.&lt;/SPAN&gt;



&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;odoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Document&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCompDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
&lt;SPAN&gt;odoc&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;
&lt;SPAN&gt;oCompDef&lt;/SPAN&gt; = &lt;SPAN&gt;odoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;


&lt;SPAN&gt;'Sets initial View Rep&lt;/SPAN&gt;
&lt;SPAN&gt;oActiveViewRep&lt;/SPAN&gt; = &lt;SPAN&gt;oCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;RepresentationsManager&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDesignViewRepresentation&lt;/SPAN&gt;



&lt;SPAN&gt;'Creates New View Rep&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oviewrep2&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DesignViewRepresentation&lt;/SPAN&gt;
&lt;SPAN&gt;Try&lt;/SPAN&gt;
&lt;SPAN&gt;oCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;RepresentationsManager&lt;/SPAN&gt;.&lt;SPAN&gt;DesignViewRepresentations&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(&lt;SPAN&gt;"Active Components"&lt;/SPAN&gt;).&lt;SPAN&gt;Activate&lt;/SPAN&gt;
&lt;SPAN&gt;Catch&lt;/SPAN&gt;
 &lt;SPAN&gt;oviewrep2&lt;/SPAN&gt; = &lt;SPAN&gt;oCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;RepresentationsManager&lt;/SPAN&gt;.&lt;SPAN&gt;DesignViewRepresentations&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;"Active Components"&lt;/SPAN&gt;)
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Try&lt;/SPAN&gt;

&lt;SPAN&gt;'This turns off some object types in view rep&lt;/SPAN&gt;
&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;odoc&lt;/SPAN&gt;.&lt;SPAN&gt;DocumentType&lt;/SPAN&gt; = &lt;SPAN&gt;kAssemblyDocumentObject&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
  &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;.&lt;SPAN&gt;ObjectVisibility&lt;/SPAN&gt;.&lt;SPAN&gt;WeldmentSymbols&lt;/SPAN&gt; = &lt;SPAN&gt;False&lt;/SPAN&gt; 
  &lt;SPAN&gt;'ThisApplication.ActiveDocument.ObjectVisibility.Welds = False&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt; 



&lt;SPAN&gt;'This sets some parameters to turn off ref components &lt;/SPAN&gt;
&lt;SPAN&gt;oAssemblyComponents&lt;/SPAN&gt; = &lt;SPAN&gt;oCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;Occurrences&lt;/SPAN&gt;

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOccurrence&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt;


    &lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oOccurrence&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oAssemblyComponents&lt;/SPAN&gt;
        &lt;SPAN&gt;If&lt;/SPAN&gt; (&lt;SPAN&gt;oOccurrence&lt;/SPAN&gt;.&lt;SPAN&gt;BOMStructure&lt;/SPAN&gt; = &lt;SPAN&gt;BOMStructureEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kReferenceBOMStructure&lt;/SPAN&gt;) &lt;SPAN&gt;Then&lt;/SPAN&gt;
            &lt;SPAN&gt;oOccurrence&lt;/SPAN&gt;.&lt;SPAN&gt;Visible&lt;/SPAN&gt; = &lt;SPAN&gt;False&lt;/SPAN&gt;
        &lt;SPAN&gt;Else&lt;/SPAN&gt;
            &lt;SPAN&gt;oOccurrence&lt;/SPAN&gt;.&lt;SPAN&gt;Visible&lt;/SPAN&gt; = &lt;SPAN&gt;True&lt;/SPAN&gt;
        &lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
    &lt;SPAN&gt;Next&lt;/SPAN&gt;

&lt;SPAN&gt;'Sets the view rep back to the one that was active before the rule was executed&lt;/SPAN&gt;
&lt;SPAN&gt;oActiveViewRep&lt;/SPAN&gt;.&lt;SPAN&gt;Activate&lt;/SPAN&gt; &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 20:10:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/re-ilogic-rule-to-find-all-reference-parts-and-turn-off/m-p/10622486#M128879</guid>
      <dc:creator>steveh3</dc:creator>
      <dc:date>2021-09-14T20:10:11Z</dc:date>
    </item>
  </channel>
</rss>

