//Script Name: acRenderPrintCalculator.mel //Author: Allen Curtis //Description: Print-size calculator //Date: June 2007 //Email: allenatl@allen3d.com //Details: //The checkbox option for Keep Same Pixel Amount //must remain unchecked for render and print size calculations. //That is the default setting. //If the option is checked, entering a new resolution //in the Resolution textfield updates the Print Size //when the Enter key is pressed. global proc acRenderPrintCalculator(){ if(`window -exists acRenderWindow`) deleteUI acRenderWindow; window -widthHeight 300 200 -title "acRenderPrintCalculator" -rtf true acRenderWindow; string $outerLayout = `formLayout -numberOfDivisions 100`; columnLayout -columnAttach "left" 10 -columnOffset "both" 5 -rs 5 ColumnLayout; floatFieldGrp -numberOfFields 2 -label "Print Size in Inches:" -v1 8.5 -v2 11.0 -pre 2 -en true renderInchField; floatFieldGrp -numberOfFields 2 -label "Render Size in Pixels" -v1 612.0 -v2 792.0 -pre 1 pixelsField; //Change command (-cc) updates size when resolution is changed. floatFieldGrp -numberOfFields 1 -label "Resolution" -v1 72 -cc "acResize" -pre 6 resolutionField; floatFieldGrp -numberOfFields 1 -label "RGB File Size (MB)" -en false -v1 1.386749 -pre 6 rgbField; floatFieldGrp -numberOfFields 1 -label "CMYK File Size (MB)" -en false -v1 1.848999 -pre 6 cmykField; checkBox -label "Keep Same Pixel Amount With New Resolution" -value 0 noResample; //Layout nested inside another layout. rowLayout -numberOfColumns 7 MainRowLayout; columnLayout -columnAttach "both" 5 -rowSpacing 10 -parent MainRowLayout Column1; button -label "Render Size" -c "acGetRenderSize" renderSizeButton; columnLayout -columnAttach "both" 5 -rowSpacing 10 -parent MainRowLayout Column2; button -label "Print Size" -c "acGetPrintSize" printSizeButton; columnLayout -columnAttach "both" 5 -rowSpacing 10 -parent MainRowLayout Column3; button -label "Close" -c "deleteUI acRenderWindow" ExitButton; formLayout -edit -attachForm ColumnLayout "top" 5 -attachForm ColumnLayout "left" 28 $outerLayout; window -edit -widthHeight 390 270 acRenderWindow; showWindow acRenderWindow; } global proc acGetRenderSize(){ float $getResolution = `floatFieldGrp -q -v1 resolutionField`; float $widthInches = `floatFieldGrp -q -v1 renderInchField`; float $heightInches = `floatFieldGrp -q -v2 renderInchField`; float $calculatePixelWidth = $getResolution * $widthInches; float $calculatePixelHeight = $getResolution * $heightInches; floatFieldGrp -edit -v1 $calculatePixelWidth pixelsField; floatFieldGrp -edit -v2 $calculatePixelHeight pixelsField; getRenderFileSize; } global proc acGetPrintSize(){ float $getResolution = 72.0; float $widthPixels = `floatFieldGrp -q -v1 pixelsField`; float $heightPixels = `floatFieldGrp -q -v2 pixelsField`; float $calculatePrintWidth = $widthPixels / $getResolution; float $calculatePrintHeight = $heightPixels / $getResolution; floatFieldGrp -edit -v1 $calculatePrintWidth renderInchField; floatFieldGrp -edit -v2 $calculatePrintHeight renderInchField; floatFieldGrp -edit -v1 72 resolutionField; getRenderFileSize; } global proc getRenderFileSize(){ float $widthPixels = `floatFieldGrp -q -v1 pixelsField`; float $heightPixels = `floatFieldGrp -q -v2 pixelsField`; float $rgb = 3; float $cmyk = 4; float $byte = 1024; float $rgbSize = ((($widthPixels*$heightPixels)*$rgb)/$byte)/$byte; float $cmykSize = ((($widthPixels*$heightPixels)*$cmyk)/$byte)/$byte; floatFieldGrp -edit -v1 $rgbSize rgbField; floatFieldGrp -edit -v1 $cmykSize cmykField; } //Resize without resampling pixels-Keeps same total amount of pixels while resizing. // Updates size when new resolution is entered. global proc acResize(){ int $resize=`checkBox -query -value noResample`; if($resize==1){ float $widthPixels = `floatFieldGrp -q -v1 pixelsField`; float $heightPixels = `floatFieldGrp -q -v2 pixelsField`; float $getRes = `floatFieldGrp -q -v1 resolutionField`; float $resizeWidth = $widthPixels/ $getRes; float $resizeHeight = $heightPixels/$getRes; floatFieldGrp -edit -v1 $resizeWidth renderInchField; floatFieldGrp -edit -v2 $resizeHeight renderInchField; } }