Page 1 of 1
Calculation Precission mm rounded no decimals
Posted: Tue Oct 03, 2017 12:15 pm
by kumpelj
Hi,
If i convert the trimbox size by Switch Calculation (pt > mm), with a precision of 2
i do not wan't to see decimals if they there is not meaningful
For instance: 420.00 mm
Should be: 420 mm
Rounded by ceil expression does not work.
How can i fix this?

- Switch Calculation Screen 2-1 Decimals.png (159.84 KiB) Viewed 10389 times
Re: Calculation Precission mm rounded no decimals
Posted: Mon Oct 09, 2017 1:36 pm
by loicaigon
Don't think you can get this in one pass. I don't know what is the final intention but you might need the scripting module to implement such logic.
Re: Calculation Precission mm rounded no decimals
Posted: Mon Oct 09, 2017 4:24 pm
by Padawan
You can also use the round function which is mentioned in the description on your screenshot.
For example, you can just place the round around the complete expression, for example like this:
[Switch.Calculation:Expression="round([Stats.MediaBoxHeight:Type="Defined"])"]
Edit: That will of course round the complete thing. If you only want to remove the obsolete zero's I also think you'll need the scripting module.
Re: Calculation Precission mm rounded no decimals
Posted: Thu Oct 12, 2017 6:13 pm
by LasseThid
If you have the Switch Scripting module then this javascript will do what you ask for.
The resulting values can be accessed thru Job>PrivateData Key New_Height and New_Width.
Code: Select all
function jobArrived( s : Switch, job : Job )
{
var width = job.getVariableAsNumber("[Stats.TrimboxWidth]");
var height = job.getVariableAsNumber("[Stats.TrimboxHeight]");
var inputJob = job.getPath();
var theFileName = job.getNameProper()
New_Width = Math.floor((width/72)*25.4+0.5);
New_Height = Math.floor((height/72)*25.4+0.5);
job.setPrivateData( ”New_Width", New_Width );
job.setPrivateData( "New_Height", New_Height );
job.sendToSingle( inputJob, theFileName );
}