<?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 Problem with very simple script in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290685#M5350</link>
    <description>&lt;P&gt;So I'm making this very simple UVW script which just applies a box UVW map with an inputted value, here it is in all of it's glory:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;v = getKBValue prompt:"Enter object count:"&lt;/P&gt;&lt;P&gt;modPanel.addModToSelection (Uvwmap ())&lt;BR /&gt;$.modifiers[#UVW_Map].maptype = 4&lt;BR /&gt;$.modifiers[#UVW_Map].length = v&lt;BR /&gt;$.modifiers[#UVW_Map].width = v&lt;BR /&gt;$.modifiers[#UVW_Map].height = v&lt;BR /&gt;&lt;BR /&gt;This works just fine from the script editor but when I make it a macro script so I can set a hotkey to it I can only use it once and then I get this error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AgustinLanus_0-1620159934560.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/915286i22D9C886CF412C05/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AgustinLanus_0-1620159934560.png" alt="AgustinLanus_0-1620159934560.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know what may be happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 May 2021 20:32:27 GMT</pubDate>
    <dc:creator>AgustinLanus</dc:creator>
    <dc:date>2021-05-04T20:32:27Z</dc:date>
    <item>
      <title>Problem with very simple script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290685#M5350</link>
      <description>&lt;P&gt;So I'm making this very simple UVW script which just applies a box UVW map with an inputted value, here it is in all of it's glory:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;v = getKBValue prompt:"Enter object count:"&lt;/P&gt;&lt;P&gt;modPanel.addModToSelection (Uvwmap ())&lt;BR /&gt;$.modifiers[#UVW_Map].maptype = 4&lt;BR /&gt;$.modifiers[#UVW_Map].length = v&lt;BR /&gt;$.modifiers[#UVW_Map].width = v&lt;BR /&gt;$.modifiers[#UVW_Map].height = v&lt;BR /&gt;&lt;BR /&gt;This works just fine from the script editor but when I make it a macro script so I can set a hotkey to it I can only use it once and then I get this error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AgustinLanus_0-1620159934560.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/915286i22D9C886CF412C05/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AgustinLanus_0-1620159934560.png" alt="AgustinLanus_0-1620159934560.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know what may be happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 20:32:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290685#M5350</guid>
      <dc:creator>AgustinLanus</dc:creator>
      <dc:date>2021-05-04T20:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with very simple script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290793#M5351</link>
      <description>&lt;P&gt;Also if I try to run it with a hotkey on more than one object at the same time I get this error every time:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AgustinLanus_0-1620163516775.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/915319iE1C1F5B05A22ACA1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AgustinLanus_0-1620163516775.png" alt="AgustinLanus_0-1620163516775.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Which also doesn't appear when I run it from the script editor&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 21:26:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290793#M5351</guid>
      <dc:creator>AgustinLanus</dc:creator>
      <dc:date>2021-05-04T21:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with very simple script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290907#M5352</link>
      <description>&lt;P&gt;In MXS, a single $ signifies the current selection. In the case where only one node is currently selected, it returns the actual node, but in the case of multiple selection, it returns a set of objects, which in general cannot provide access to the node's parameters (e.g. #modifiers in your particular case).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, it is the good practice to never use the $ character in max scripts, but only use it for quick and dirty typing in the Listener.&lt;/P&gt;&lt;P&gt;Instead of using $ use &lt;STRONG&gt;selection[1]&lt;/STRONG&gt;, which is always the first node selected, or undefined if nothing is selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The&amp;nbsp; code in your case might look as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(
	if isvalidnode (n = selection[1]) do
	(
		m = n.modifiers[#UVW_Map]
		if m != undefined do
		(
			m.maptype = 4
			m.length = m.width = m.height = v
		)
	)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 22:47:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290907#M5352</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-05-04T22:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with very simple script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290922#M5353</link>
      <description>&lt;P&gt;If you want to add one (the same) instance of the UVW Map modifier to a multiple selection, the correct way to do it is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(
	m = UVWMap maptype:4 length:v width:v height:v

	modPanel.addModToSelection m
	-- or
	addmodifier selection m
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 23:01:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290922#M5353</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-05-04T23:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with very simple script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290925#M5354</link>
      <description>&lt;P&gt;That certainly looks a lot cleaner!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I'm probably missing something really basic as I barely understand maxscript yet but should I be getting "undefined" when I run that code as it is?&lt;BR /&gt;I just added&amp;nbsp;v = getKBValue prompt:"Enter object count:" at the top to input the value&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 23:01:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290925#M5354</guid>
      <dc:creator>AgustinLanus</dc:creator>
      <dc:date>2021-05-04T23:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with very simple script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290935#M5355</link>
      <description>&lt;P&gt;Yes! this does the trick to add the modifier to any amount of objects, so that's one down but for some reason I still get get errors when I run it with a hotkey every other use.&lt;BR /&gt;What's the correct way to make a script go from the script editor into a hotkey? I use the macroScriptCreator script to turn them into macroscripts which I can then easily access but that seems to be breaking something here.&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 23:08:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10290935#M5355</guid>
      <dc:creator>AgustinLanus</dc:creator>
      <dc:date>2021-05-04T23:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with very simple script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10291071#M5356</link>
      <description>&lt;P&gt;I would do something more intuitive and visually more accessible ... Something like:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(
	result = false
	if selection.count &amp;gt; 0 do
	(
		rollout type_a_number_Rollout "UVW size:" width:134
		(
			local value
			
			edittext text_input width:130 pos:[0,5]
			on text_input entered text do
			(
				v = try(text as float) catch()
				if isnumber v then 
				(
					value = v
					destroydialog type_a_number_Rollout 
				)
				else
				(
					text_input.text = ""
					setfocus text_input
				)
			)
			on type_a_number_Rollout open do setfocus text_input
		)
		createdialog type_a_number_Rollout modal:on

		if isnumber (v = type_a_number_Rollout.value) do undo "Add UVW Modifier" on
		(
			uvw_mod = uvwmap width:v length:v height:v
			addmodifier selection  uvw_mod
			
			result = true	
		)
	)
	
	format (if result then "SUCCEEDED!\n" else "FAILED!\n")
	
	result
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 00:45:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10291071#M5356</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-05-05T00:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with very simple script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10291167#M5357</link>
      <description>&lt;P&gt;I love the idea of having that messagebox appear for the input but sadly for some reason that code isn't compiling for me, after typing a number and pressing enter I just get errors.&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 02:28:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/problem-with-very-simple-script/m-p/10291167#M5357</guid>
      <dc:creator>AgustinLanus</dc:creator>
      <dc:date>2021-05-05T02:28:04Z</dc:date>
    </item>
  </channel>
</rss>

