<?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 Betreff: View Representations with iLogic: Error Object variable or With block variable not set. in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/view-representations-with-ilogic-error-object-variable-or-with/m-p/10360197#M49255</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You definie a variable oOcc but don't assign a value or object to it.&lt;/P&gt;&lt;P&gt;Try&lt;/P&gt;&lt;LI-CODE lang="general"&gt;' ********************
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOccs as ComponentOccurrences= oAsmCompDef.Occurrences

'Activate a writeable View Rep (master view rep is not writeable)
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("BOTTOM FLANGE").Activate

' Set component View Rep
oOccs.ItemByName("FLANGE_BOTTOM_#3:1").SetDesignViewRepresentation("Default",,)
oOccs.ItemByName("FLANGE_BOTTOM_#4:1").SetDesignViewRepresentation("Default", , )
oOccs.ItemByName("FLANGE_BOTTOM_#5:1").SetDesignViewRepresentation("MATERIAL ORDER",,)

' ********************&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jun 2021 06:42:44 GMT</pubDate>
    <dc:creator>Ralf_Krieg</dc:creator>
    <dc:date>2021-06-03T06:42:44Z</dc:date>
    <item>
      <title>View Representations with iLogic: Error Object variable or With block variable not set.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/view-representations-with-ilogic-error-object-variable-or-with/m-p/10359274#M49253</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am relatively new to iLogic and am struggling with controlling view reps at assembly and at component level using iLogic rules in the assembly level document. I have searched the forum and API help and haven't quite found what I'm looking for. Hoping someone can shed some light on this for me...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Design intent:&lt;/P&gt;&lt;P&gt;Configure various view reps at assembly level to show a group of components in a steel crane girder that have specific component level view reps that are setup to show different states of fabrication. In this case one of the groups is a line of steel plates spliced together that forms the bottom flange of the girder. There are other rules that set the length, suppression and constraints of the plates. In the assembly level view rep, all of the individual bottom flange components must be in their default (fabricated) view rep, except the last component which needs to be in its "MATERIAL ORDER" view rep that shows the other side of a split used to hide/show the trim length allowed for in the component.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried a simple piece of code to trial the view rep based on one configuration only, but it kicks out the error: Object variable or With block variable not set.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rogerJDLE5_0-1622665606325.png" style="width: 332px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/925895iAD088BE4437A0B73/image-dimensions/332x251?v=v2" width="332" height="251" role="button" title="rogerJDLE5_0-1622665606325.png" alt="rogerJDLE5_0-1622665606325.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code I tried. Anyone able to see why I'm getting the error above?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;' ********************&lt;BR /&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oAsmCompDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyComponentDefinition&lt;/SPAN&gt;
&lt;SPAN&gt;oAsmCompDef&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt;

&lt;SPAN&gt;'Activate a writeable View Rep (master view rep is not writeable)&lt;/SPAN&gt;
&lt;SPAN&gt;oAsmCompDef&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;"BOTTOM FLANGE"&lt;/SPAN&gt;).&lt;SPAN&gt;Activate&lt;/SPAN&gt;

&lt;SPAN&gt;' Set component View Rep&lt;/SPAN&gt;
&lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;ItemByName&lt;/SPAN&gt;(&lt;SPAN&gt;"FLANGE_BOTTOM_#3:1"&lt;/SPAN&gt;).&lt;SPAN&gt;SetDesignViewRepresentation&lt;/SPAN&gt;(&lt;SPAN&gt;"Default"&lt;/SPAN&gt;,,)
&lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;ItemByName&lt;/SPAN&gt;(&lt;SPAN&gt;"FLANGE_BOTTOM_#4:1"&lt;/SPAN&gt;).&lt;SPAN&gt;SetDesignViewRepresentation&lt;/SPAN&gt;(&lt;SPAN&gt;"Default"&lt;/SPAN&gt;, , )
&lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;ItemByName&lt;/SPAN&gt;(&lt;SPAN&gt;"FLANGE_BOTTOM_#5:1"&lt;/SPAN&gt;).&lt;SPAN&gt;SetDesignViewRepresentation&lt;/SPAN&gt;(&lt;SPAN&gt;"MATERIAL ORDER"&lt;/SPAN&gt;,,)

&lt;SPAN&gt;' ********************&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 20:29:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/view-representations-with-ilogic-error-object-variable-or-with/m-p/10359274#M49253</guid>
      <dc:creator>rogerJDLE5</dc:creator>
      <dc:date>2021-06-02T20:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: View Representations with iLogic: Error Object variable or With block variable not set.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/view-representations-with-ilogic-error-object-variable-or-with/m-p/10360194#M49254</link>
      <description>&lt;P&gt;Welcome to the forum, it is a lot like cracking a nut &lt;span class="lia-unicode-emoji" title=":chipmunk:"&gt;🐿&lt;/span&gt; Be persistent&lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;View reps are tricky for sure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just looking at the code the first thing that stands out is the variable oOcc hasn’t been set to a specific assembly. &amp;nbsp;&lt;BR /&gt;Next thing is you will need to loop through each occurrence in the assembly if you intend to set the view rep. Then in the loop, filter for the occurrence you want and then do something with it.&lt;/P&gt;&lt;P&gt;The snippet below sets the variable and loops at the same time.&lt;/P&gt;&lt;PRE&gt;For Each oOcc In oAsmCompDef.Occurrences&lt;BR /&gt;&lt;BR /&gt;‘Filter......&lt;BR /&gt;&lt;SPAN&gt;If oOcc.Name =???&lt;/SPAN&gt;&lt;BR /&gt;‘Do something......&lt;BR /&gt;Next&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Post similar to your request and for sub assemblies&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-customization/ilogic-sub-assembly-set-view-rep/td-p/7362982" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-customization/ilogic-sub-assembly-set-view-rep/td-p/7362982&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Might be helpful.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;"&gt;&lt;BR /&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-customization/ilogic-view-representation/td-p/4668063" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-customization/ilogic-view-representation/td-p/4668063&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;"&gt;Need anymore help, ask away!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 06:41:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/view-representations-with-ilogic-error-object-variable-or-with/m-p/10360194#M49254</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2021-06-03T06:41:43Z</dc:date>
    </item>
    <item>
      <title>Betreff: View Representations with iLogic: Error Object variable or With block variable not set.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/view-representations-with-ilogic-error-object-variable-or-with/m-p/10360197#M49255</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You definie a variable oOcc but don't assign a value or object to it.&lt;/P&gt;&lt;P&gt;Try&lt;/P&gt;&lt;LI-CODE lang="general"&gt;' ********************
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOccs as ComponentOccurrences= oAsmCompDef.Occurrences

'Activate a writeable View Rep (master view rep is not writeable)
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("BOTTOM FLANGE").Activate

' Set component View Rep
oOccs.ItemByName("FLANGE_BOTTOM_#3:1").SetDesignViewRepresentation("Default",,)
oOccs.ItemByName("FLANGE_BOTTOM_#4:1").SetDesignViewRepresentation("Default", , )
oOccs.ItemByName("FLANGE_BOTTOM_#5:1").SetDesignViewRepresentation("MATERIAL ORDER",,)

' ********************&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 06:42:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/view-representations-with-ilogic-error-object-variable-or-with/m-p/10360197#M49255</guid>
      <dc:creator>Ralf_Krieg</dc:creator>
      <dc:date>2021-06-03T06:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: View Representations with iLogic: Error Object variable or With block variable not set.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/view-representations-with-ilogic-error-object-variable-or-with/m-p/10362444#M49256</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7946284"&gt;@A.Acheson&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the empathetic and helpful response!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this initial trial piece of code now that seems to run well:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;doc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;  
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oAsmCompDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;  
&lt;SPAN&gt;oAsmCompDef&lt;/SPAN&gt; = &lt;SPAN&gt;doc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt; 
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCompOcc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt;

&lt;SPAN&gt;'Activate a writeable View Rep (master view rep is not writeable)&lt;/SPAN&gt;
&lt;SPAN&gt;oAsmCompDef&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;"BOTTOM FLANGE"&lt;/SPAN&gt;).&lt;SPAN&gt;Activate&lt;/SPAN&gt;

&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oCompOcc&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oAsmCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;Occurrences&lt;/SPAN&gt;
&lt;SPAN&gt;'	Filter......&lt;/SPAN&gt;
	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; = &lt;SPAN&gt;"FLANGE_BOTTOM_#2:1"&lt;/SPAN&gt; &lt;SPAN&gt;And&lt;/SPAN&gt; &lt;SPAN&gt;BF_LENGTH_3&lt;/SPAN&gt; = 0 &lt;SPAN&gt;Then&lt;/SPAN&gt;
		&lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;SetDesignViewRepresentation&lt;/SPAN&gt;(&lt;SPAN&gt;"MATERIAL ORDER"&lt;/SPAN&gt;, &lt;SPAN&gt;True&lt;/SPAN&gt;)
		
	&lt;SPAN&gt;ElseIf&lt;/SPAN&gt; &lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; = &lt;SPAN&gt;"FLANGE_BOTTOM_#2:1"&lt;/SPAN&gt; &lt;SPAN&gt;And&lt;/SPAN&gt; &lt;SPAN&gt;BF_LENGTH_3&lt;/SPAN&gt; &amp;gt; 0 &lt;SPAN&gt;Then&lt;/SPAN&gt;
		&lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;SetDesignViewRepresentation&lt;/SPAN&gt;(&lt;SPAN&gt;"Default"&lt;/SPAN&gt;, &lt;SPAN&gt;True&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;ElseIf&lt;/SPAN&gt; &lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; = &lt;SPAN&gt;"FLANGE_BOTTOM_#3:1"&lt;/SPAN&gt; &lt;SPAN&gt;And&lt;/SPAN&gt; &lt;SPAN&gt;BF_LENGTH_4&lt;/SPAN&gt; = 0 &lt;SPAN&gt;Then&lt;/SPAN&gt;
		&lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;SetDesignViewRepresentation&lt;/SPAN&gt;(&lt;SPAN&gt;"MATERIAL ORDER"&lt;/SPAN&gt;, &lt;SPAN&gt;True&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;ElseIf&lt;/SPAN&gt; &lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; = &lt;SPAN&gt;"FLANGE_BOTTOM_#3:1"&lt;/SPAN&gt; &lt;SPAN&gt;And&lt;/SPAN&gt; &lt;SPAN&gt;BF_LENGTH_4&lt;/SPAN&gt; &amp;gt; 0 &lt;SPAN&gt;Then&lt;/SPAN&gt;
		&lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;SetDesignViewRepresentation&lt;/SPAN&gt;(&lt;SPAN&gt;"Default"&lt;/SPAN&gt;, &lt;SPAN&gt;True&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;ElseIf&lt;/SPAN&gt; &lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; = &lt;SPAN&gt;"FLANGE_BOTTOM_#4:1"&lt;/SPAN&gt; &lt;SPAN&gt;And&lt;/SPAN&gt; &lt;SPAN&gt;BF_LENGTH_5&lt;/SPAN&gt; = 0 &lt;SPAN&gt;Then&lt;/SPAN&gt;
		&lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;SetDesignViewRepresentation&lt;/SPAN&gt;(&lt;SPAN&gt;"MATERIAL ORDER"&lt;/SPAN&gt;, &lt;SPAN&gt;True&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;ElseIf&lt;/SPAN&gt; &lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; = &lt;SPAN&gt;"FLANGE_BOTTOM_#4:1"&lt;/SPAN&gt; &lt;SPAN&gt;And&lt;/SPAN&gt; &lt;SPAN&gt;BF_LENGTH_5&lt;/SPAN&gt; &amp;gt; 0 &lt;SPAN&gt;Then&lt;/SPAN&gt;
		&lt;SPAN&gt;oCompOcc&lt;/SPAN&gt;.&lt;SPAN&gt;SetDesignViewRepresentation&lt;/SPAN&gt;(&lt;SPAN&gt;"Default"&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;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveView&lt;/SPAN&gt;.&lt;SPAN&gt;Fit&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Jun 2021 22:19:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/view-representations-with-ilogic-error-object-variable-or-with/m-p/10362444#M49256</guid>
      <dc:creator>rogerJDLE5</dc:creator>
      <dc:date>2021-06-03T22:19:45Z</dc:date>
    </item>
  </channel>
</rss>

