PDA

View Full Version : Maxscript help


Big10
02-20-2009, 11:58 AM
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

"

Buzzy
02-20-2009, 01:21 PM
looks like your missing a viewport and a target
Here is a bit of code from a rendering script I wrote:

tempImg = render camera:$Camera01 frame:0 outputSize:[512,512]


The renderer needs a viewport to render (in this case is Camera01)
The renderer also needs to put the final rendered image into some target, in this case it is tempImg (by writing "tempImg = render..." max will automatically make tempImg a bitmap that you can then save out to a file)

Big10
02-20-2009, 08:24 PM
looks like your missing a viewport and a target
Here is a bit of code from a rendering script I wrote:

tempImg = render camera:$Camera01 frame:0 outputSize:[512,512]


The renderer needs a viewport to render (in this case is Camera01)
The renderer also needs to put the final rendered image into some target, in this case it is tempImg (by writing "tempImg = render..." max will automatically make tempImg a bitmap that you can then save out to a file)

thanks for the help !
but i ran into another problem, i put that code you gave me into my script, but it doesn;t seem to work. So.. where actually do i insert this ? i put it in after before the render() in the 25% button.

Buzzy
02-23-2009, 11:32 AM
Just replace the whole button with this:

--25% Button
on my25Bt pressed do
(
--Converts spinner values
xWidth = .25 * myrenderWidth.value
xHeight = .25 * myrenderHeight.value

imgFile = "C:\\outputImage.tga" --replace this with whatever path and filename you want
finalImg = bitmap xWidth xHeight filename:imgFile
tempImg = render camera:$Camera01 frame:0 outputSize:[xWidth,xHeight]
copy tempImg finalImg
save finalImg
close finalImg
)


There are two images because I've found its usually better to render to a temporary bitmap, then copy that into the final image, rather than render directly into your final image