<?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: Light include/exclude list....format items in array? in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5768711#M15133</link>
    <description>&lt;P&gt;Thank you Steve. As usual, when I post here I come up with a solution and come back and say 'duh, never mind guys, I figgered it out'....it seems the prime ingredient in my solution is to make myself look dumb on a forum and I come up with the answer! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case I tried to do exactly what you're saying and I came up with this, and it sort of works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;for i in lights where (classof i != Targetobject) do

		if (i.includelist != undefined) then
			(
				print (i.name + " Includes:")
				
				_incl = (i.includelist)
				for j=1 to _incl.count do
					(
					print _incl[j].name
					)
			)
		else
			if (i.excludelist != undefined) then
			(
				print (i.name + " Excludes:")
				
				_excl = (i.excludelist)
				for k=1 to _excl.count do
					(
					print _excl[k].name
					)				
			)
			else()&lt;/PRE&gt;&lt;P&gt;This does work for me but the problem is it prints all the lights, not just the ones with include or exclude. Seems my conditional statement is wrong somewhere. Does this make sense??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much! Love this forum.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Aug 2015 20:52:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-08-12T20:52:47Z</dc:date>
    <item>
      <title>Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5768623#M15131</link>
      <description>&lt;P&gt;Hello friends, I am trying to do a simple script for listing scene lights that have an include or exclude, and also print a list of the included/excluded items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this for a start (filtering out the light targets):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;for i in lights where (classof i != Targetobject) do
		if (i.includelist != undefined) then
		(
			print (i.name + " Includes these items:")
			print i.includelist
		)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...and it gives me this result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"VRayLight001 Includes these items:"&lt;BR /&gt;$Box:Box001 @ [-35.890526,34.681732,0.000000]&lt;BR /&gt;$Box:Box002 @ [5.210434,31.309677,0.000000]&lt;BR /&gt;$Box:Box003 @ [5.210434,-8.237305,0.000000]&lt;BR /&gt;OK&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to format the items in the includelist array so that only the names will be printed. If I try this:&lt;/P&gt;&lt;PRE&gt;for i in lights where (classof i != Targetobject) do
		if (i.includelist != undefined) then
		(
			print (i.name + " Includes these items:")
			
			for item in (i.includelist) to (i.includelist.count) do
				(
				print item.name
				)
		)&lt;/PRE&gt;&lt;P&gt;....it throws an error, saying it's unable to convert the items in the array to integer. The problem seems to be with me not knowing how to format the result as object names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could use a gentle push in the right direction. Any help or advice is most welcome. Thanks for your time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2015 19:57:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5768623#M15131</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-12T19:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5768662#M15132</link>
      <description>You were almost there. The includelist is an array therefore you need to index into the array to get at each item in the list and only then can you access its Name property.&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;for theLight in lights where (classof theLight != Targetobject) do
	(
	if (theLight.includelist != undefined) then
		(
		print (theLight.name + " Includes these items:")
		for listItem = 1 to theLight.includelist.count do
			print theLight.includeList[listItem].name
		)
	)
&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Aug 2015 20:22:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5768662#M15132</guid>
      <dc:creator>Steve_Curley</dc:creator>
      <dc:date>2015-08-12T20:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5768711#M15133</link>
      <description>&lt;P&gt;Thank you Steve. As usual, when I post here I come up with a solution and come back and say 'duh, never mind guys, I figgered it out'....it seems the prime ingredient in my solution is to make myself look dumb on a forum and I come up with the answer! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case I tried to do exactly what you're saying and I came up with this, and it sort of works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;for i in lights where (classof i != Targetobject) do

		if (i.includelist != undefined) then
			(
				print (i.name + " Includes:")
				
				_incl = (i.includelist)
				for j=1 to _incl.count do
					(
					print _incl[j].name
					)
			)
		else
			if (i.excludelist != undefined) then
			(
				print (i.name + " Excludes:")
				
				_excl = (i.excludelist)
				for k=1 to _excl.count do
					(
					print _excl[k].name
					)				
			)
			else()&lt;/PRE&gt;&lt;P&gt;This does work for me but the problem is it prints all the lights, not just the ones with include or exclude. Seems my conditional statement is wrong somewhere. Does this make sense??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much! Love this forum.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2015 20:52:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5768711#M15133</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-12T20:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5768788#M15134</link>
      <description>You need to test not only for the existence of the list but also its length, because the default is an Exclude list (of 0 length). It's also possible to set it to an empty Include list hence the same tests in both cases.&lt;BR /&gt;
You can do that in a single compound statement because Maxscript uses Short Circuit evaluation of tests so if the first one fails the second is never evaluated (and would cause an error if it was).&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;for L in lights where (classof L != Targetobject) do
	(
	if ((L.includelist != undefined) and (L.includelist.count != 0)) then
		(
		print (L.name + " Includes:")

		_incl = L.includelist
		for j = 1 to _incl.count do
			print _incl[j].name
		)
	else
		(
		if ((L.excludelist != undefined) and (L.excludelist.count != 0)) then
			(
			print (L.name + " Excludes:")

			_excl = (L.excludelist)
			for j= 1 to _excl.count do
				print _excl[j].name
			)				
		)
	)
&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Aug 2015 21:50:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5768788#M15134</guid>
      <dc:creator>Steve_Curley</dc:creator>
      <dc:date>2015-08-12T21:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769204#M15135</link>
      <description>&lt;P&gt;It's worth mentioning that some lights don't have includelist/excludelist properties (for example mr_Sky). And you don't need to check for targetobject, that one belongs to the geometry collection. So the first line should rather be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;for L in lights where isProperty L #includelist do ...&lt;/PRE&gt;&lt;P&gt;My preference would also be to iterate the array directly (readability is the biggest point here), i.e. ,&lt;FONT face="courier new,courier"&gt; for obj in L.includelist do print obj.name&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier"&gt;_incl = L.includelist; for j = 1 to _incl.count do print _incl[j].name&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 06:54:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769204#M15135</guid>
      <dc:creator>Swordslayer</dc:creator>
      <dc:date>2015-08-13T06:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769640#M15136</link>
      <description>&lt;P&gt;Ah yes, I didn't think of that! So each light by default has an include/exclude list even if it's empty, so it still has an array even if it's empty. Makes perfect sense, thank you so much Steve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What a great forum.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:29:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769640#M15136</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T13:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769654#M15137</link>
      <description>&lt;P&gt;Swordslayer, thank you, I will definitely study your suggestion. I'm a bit confused though; I filtered the list for targets because I kept getting an error when I ran the for loop for lights.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't expect targets to show up in the findings either, but once I filtered for them the error went away. So I don't quite understand that part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your suggestion will be really good for me to study. Thanks very much!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:32:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769654#M15137</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T13:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769675#M15138</link>
      <description>&lt;P&gt;Interesting - you're right, targets are included, too. Eitherway, since they don't have the includelist property, they are still eliminated this way.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:40:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769675#M15138</guid>
      <dc:creator>Swordslayer</dc:creator>
      <dc:date>2015-08-13T13:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769810#M15139</link>
      <description>&lt;P&gt;swordslayer, the readbility fix is perfect. thank you. It looks like I still need to filter for targets though. Perhaps I'm missing something? &amp;nbsp; Thanks very much.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 14:30:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769810#M15139</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T14:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769907#M15140</link>
      <description>&lt;P&gt;Yes they are. I incorporated both yours and Steve Curley's suggestions into the script and it seems fine now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem is I tried it on a big file and I'm getting an error at the end. I'm going to try and get to the bottom of it and I might have to come back for more advice....probably shouldn't have designated those answers as solutions until I tested it more....sorry. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 15:13:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769907#M15140</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T15:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Light include/exclude list....format items in array?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769948#M15141</link>
      <description>Even more interesting: it throws an error if I load vray light lister...so the prob might not be in this script. Troubleshooting...&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Aug 2015 15:29:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/light-include-exclude-list-format-items-in-array/m-p/5769948#M15141</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T15:29:55Z</dc:date>
    </item>
  </channel>
</rss>

