<?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: Autodesk Inventor iLogic to set active lighting style in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8120428#M86418</link>
    <description>&lt;P&gt;You saw the bit in my reply that said "pseudo-code" right?&amp;nbsp;&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&amp;nbsp;&lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://forums.autodesk.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The best thing you can do is share what code you have for me/others to see.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jul 2018 12:42:18 GMT</pubDate>
    <dc:creator>AlexFielder</dc:creator>
    <dc:date>2018-07-10T12:42:18Z</dc:date>
    <item>
      <title>Autodesk Inventor iLogic to set active lighting style</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8110990#M86220</link>
      <description>&lt;P&gt;Please could you help me to set the active lighting style with iLogic?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code will get the active lighting style name, but I can't set the active lighting style - what am I missing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim oAssy As AssemblyDocument = ThisApplication.ActiveDocument

Dim oLightStyleName As String 

oLightStyleName = oAssy.ActiveLightingStyle.Name

MessageBox.Show(oLightStyleName, "Title")

'This line doesn't work
oAssy.ActiveLightingStyle.Name = "Grid Light"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S. I found this post on the manufacturing dev blog. I have converted it to iLogic, but it doesn't work for me &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@F462EEC827775DA92CB03B7FC147D389/emoticons/1f61e.png" alt=":disappointed_face:" title=":disappointed_face:" /&gt;&lt;BR /&gt;&lt;A href="http://adndevblog.typepad.com/manufacturing/2015/07/change-activelightingstyle.html" target="_blank"&gt;http://adndevblog.typepad.com/manufacturing/2015/07/change-activelightingstyle.html&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;Sub ChangeLightingStyle()
  Dim doc As Document
  Set doc = ThisApplication.ActiveDocument
  
  Dim lss As LightingStyles
  Set lss = doc.LightingStyles
  
  ' Let's just use the first style
  ' InternalName: "1:Cool Light"
  doc.ActiveLightingStyle = lss("1:Cool Light")
End Sub&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 11:07:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8110990#M86220</guid>
      <dc:creator>PaulMunford</dc:creator>
      <dc:date>2018-07-05T11:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Autodesk Inventor iLogic to set active lighting style</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8111691#M86240</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/270541"&gt;@PaulMunford&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Long time no see around these parts &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7B4B80143EBEB4F250CEEC82342F6CA1/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran your code and it worked the first time, but not after that in a newly created assembly file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason for this is because you were changing the name (of the active lightingstyle) to the string you desired with this line, not changing the active lightingstyle to it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;oAssy.ActiveLightingStyle.Name = "Grid Light"&lt;/PRE&gt;&lt;P&gt;I've knocked up this simple rule:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Dim oAssy As AssemblyDocument = ThisApplication.ActiveDocument

Dim oLightStyleName As String 

oLightStyleName = oAssy.ActiveLightingStyle.Name

MessageBox.Show(oLightStyleName, "Title")

Dim lightingstyletochangeto As LightingStyle = oAssy.LightingStyles.Item("Grid Light")
If Not oAssy.ActiveLightingStyle.Name = lightingstyletochangeto.Name Then
	oAssy.ActiveLightingStyle = lightingstyletochangeto
	InventorVb.DocumentUpdate()
Else
	MessageBox.Show("We're already using the desired lighting style!")
End If&lt;/PRE&gt;&lt;P&gt;Which appears on the surface to answer your question. When it runs however, the active lightingstyle on the "View" tab of the Inventor interface doesn't seem to update so there must either be:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;a bug OR&lt;/LI&gt;&lt;LI&gt;a missing update function I haven't used to update the Inventor interface&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I'm not sure which without further investigation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alex.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 15:43:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8111691#M86240</guid>
      <dc:creator>AlexFielder</dc:creator>
      <dc:date>2018-07-05T15:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Autodesk Inventor iLogic to set active lighting style</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8113021#M86271</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/270541"&gt;@PaulMunford&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try below iLogic code to set lightstyle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;BR /&gt;Dim doc As Document&lt;BR /&gt;doc = ThisApplication.ActiveDocument&lt;BR /&gt;&lt;BR /&gt;Dim ls As LightingStyle&lt;BR /&gt;If doc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then&lt;BR /&gt; &lt;BR /&gt; Dim oAssy As AssemblyDocument &lt;BR /&gt; oAssy = doc &lt;BR /&gt; &lt;BR /&gt; ls = oAssy.LightingStyles.Item("Grid Light")&lt;BR /&gt; oAssy.ActiveLightingStyle = ls&lt;BR /&gt; &lt;BR /&gt;Else If doc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then&lt;BR /&gt; Dim oPart As PartDocument &lt;BR /&gt; oPart = doc &lt;BR /&gt; &lt;BR /&gt; ls = oPart.LightingStyles.Item("Grid Light")&lt;BR /&gt; oPart.ActiveLightingStyle = ls&lt;BR /&gt; &lt;BR /&gt;End If&lt;/PRE&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 05:02:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8113021#M86271</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2018-07-06T05:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Autodesk Inventor iLogic to set active lighting style</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8113355#M86277</link>
      <description>&lt;P&gt;It was so much easier when I could just stop by your desk &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7B4B80143EBEB4F250CEEC82342F6CA1/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks very much for that - it's ideal. I understand now that I need to call it up as an item, not just change it's name. I need to get better at browsing the object model and understanding hat I can do with it &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will be back with my next question shortly - i'm sure!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 08:24:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8113355#M86277</guid>
      <dc:creator>PaulMunford</dc:creator>
      <dc:date>2018-07-06T08:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Autodesk Inventor iLogic to set active lighting style</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8113375#M86279</link>
      <description>&lt;P&gt;Awesome!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4427777"&gt;@chandra.shekar.g&lt;/a&gt;&amp;nbsp;you anticipated my next task:)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My ultimate goal is to create an iLogic rule that will step through all files in an assembly, open the file, change the lighting style and save the file - to update the thumbnail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 08:37:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8113375#M86279</guid>
      <dc:creator>PaulMunford</dc:creator>
      <dc:date>2018-07-06T08:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Autodesk Inventor iLogic to set active lighting style</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8117113#M86328</link>
      <description>&lt;P&gt;psuedo-code for that would be something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Sub Main()
dim stylename as string = "My Chosen Stylename"

For each doc as Document in ThisAssembly.AllReferencedDocuments
   If typeof doc is PartDocument then
      setPartLighting(stylename)
   else 'assembly
      setAssemblyLighting(stylename)
   end if
Next

End Sub

Sub SetPartLighting(Byval stylename as string)
 'copy in the answers from above and hope the magic smoke doesn't escape!
End Sub&lt;BR /&gt;&lt;BR /&gt;Sub SetAssemblyLighting(Byval stylename as string)
 'copy in the answers from above and hope the magic smoke doesn't escape!
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 08:31:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8117113#M86328</guid>
      <dc:creator>AlexFielder</dc:creator>
      <dc:date>2018-07-09T08:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Autodesk Inventor iLogic to set active lighting style</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8120395#M86416</link>
      <description>&lt;P&gt;That looks encouraging!&lt;/P&gt;
&lt;P&gt;I had the error:&lt;/P&gt;
&lt;P&gt;'AllReferencedDocments' is not a member of 'Autodesk.iLogic.Interfaces.iManagedAssembly' ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I changed it to:&lt;BR /&gt;&lt;SPAN&gt;ThisAssembly&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;.&lt;SPAN&gt;AllReferencedDocuments&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The code runs - but it doesn't seem to work &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@795596742BBE9063EFA1B55C0747436D/emoticons/1f615.png" alt=":confused_face:" title=":confused_face:" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;An additional question, would the part file actually need to be opened and saved to get the thumbnail to update?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 12:28:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8120395#M86416</guid>
      <dc:creator>PaulMunford</dc:creator>
      <dc:date>2018-07-10T12:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Autodesk Inventor iLogic to set active lighting style</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8120428#M86418</link>
      <description>&lt;P&gt;You saw the bit in my reply that said "pseudo-code" right?&amp;nbsp;&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&amp;nbsp;&lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://forums.autodesk.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The best thing you can do is share what code you have for me/others to see.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 12:42:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/autodesk-inventor-ilogic-to-set-active-lighting-style/m-p/8120428#M86418</guid>
      <dc:creator>AlexFielder</dc:creator>
      <dc:date>2018-07-10T12:42:18Z</dc:date>
    </item>
  </channel>
</rss>

