Reply
Reply
 
Thread Tools Display Modes
Mistry10's Avatar
Old (#1)
hey guys i'm currently working on a simple max script tool for my scripting class, and i 've ran into a problem.

i'm trying to run this command:
"render outputSize: [xWidth,xHeight]"
as you can see in the code below it takes the values inputted be the spinner and does a simple math formula. Then it should render ...but it doesn't
currently on the "25% Button" has the render code in it.

you can download the file from here:
http://www.filedropper.com/hitenmistry1




"/*
Mistry

Render Tools
This tool lets the user choice from 4 different render percents and can manully input the
width and height of the render directly into the dialog


*/
-------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
try(destroyDialog myToolUIR)catch()
rollout myToolUIR "RenderTools"
(

group "Size"
(

--renderWidth
spinner myrenderWidth "Width"

--renderHeight
spinner myrenderHeight "Height"

)

group "Render"
(
--25%
button my25Bt "25%"

--50%
button my50Bt "50%"

--75%
button my75Bt "75%"

--100%
button my100Bt "100%"
)

group "Percent"
(
--Percent
spinner myPercentSp "Percent:" feildWidth: 100 \
type:#integer range: [5,100,5]
)

--25% Button
on my25Bt pressed do
(
--Converts spinner values
.25 * myrenderWidth.value= xWidth
.25 * myrenderHeight.value= xHeight
render outputSize: [xWidth,xHeight]
--outputwidth: xWidth
--outputheight: xHeight
render()
)

--50% Button
on my50Bt pressed do
(

-- .50 * myrenderWidth= xWidth
-- .50 * myrenderHeight= xHeight
--outputwidth: <xWidth>
--outputheight: <xHeight>
--render()
)


--75% Button
on my75Bt pressed do
(

-- .75 * myrenderWidth= xWidth
-- .75 * myrenderHeight= xHeight
--outputwidth: <xWidth>
--outputheight: <xHeight>
--render()
)


--100% Button
on my100Bt pressed do
(

-- myrenderWidth= xWidth
-- myrenderHeight= xHeight
--outputwidth: <xWidth>
--outputheight: <xHeight>
--render()
)


--outputwidth: <number>
--outputheight: <number>

--render
--render()




)
createDialog myToolUIR

"
Offline , polygon, 680 Posts, Join Date Sep 2008, Location Cybertron  
   Reply With Quote

Rob Galanakis's Avatar
Old (#2)
You have a number of issues:
  1. First, it is 'fieldWidth', not 'feildWidth' (no excuse for that sort of thing!)
  2. Second, there is a problem with your variable assignment. Every coding language I know of has the variable to the left, then the equal sign, then evaluates the right side. So ".25 * myrenderHeight.value= xHeight " should be "xHeight = .25 * myRenderHeight.value"
  3. Third, you can get a 0 value for your render size, which will throw an error. Also remember that if you pass a float into a function that takes an integer (such as render()), floats ALWAYS round down to integers- so if the spinner value is 2, and you multiply it by .25, you're going to pass in a value of 0. Before calling render, therefore, you will want to check to make sure any fractional value below 1 should be set to 1.

Fourth, it is never too early to teach good code design:
You can simplify your entire script by placing this function below your rollout controls and above the event handlers:
Code:
fn doRender theScale =
(
	render outputSize:([myrenderWidth.value, myRenderHeight.value] * theScale)
)
And then all of your event handlers look like this:
Code:
on my25Bt pressed do
(
	doRender .25
)
etc.
Offline , polycounter, 927 Posts, Join Date Jan 2007, Location Reykjavik, Iceland  
   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 1998-2012 A. Risch