Variable Calculation of Text and Length

Post Reply
Keith@Studio1
Newbie
Posts: 2
Joined: Wed Sep 28, 2022 3:47 pm

Variable Calculation of Text and Length

Post by Keith@Studio1 »

I am trying to calculate a 'Change Position' Move relative by X: coordinate based upon a variable
My original artwork is at 10th scale but my work order sizes are a full scale i.e. move by 400mm needs to return a value of move by 40mm

I have set up 2 variables the first to gather the data the second to execute the calculation for the action

Variable 1
Name: Trimmed_by:
This is a CONSTANT TEXT variable with a default of 0 allowing for input
In this example the input value would be 400 when the action is run

Variable 2
Name: Trimmed_by_Calc
This is a CALCULATION BASED LENGTH
Variable Value: [Trimmed_by] / 10
This should return a value of 40mm

When I run the action the selected object only moves a fraction of the desired amount.
The move is about 1/3 of the desired amount.

--------------------------------------------------------------------------------------------------------------------------------------------

My current resolution is to run a single variable CONSTANT LENGTH and just remember to use 10th scale measurements.
However its bugging me that I cant get the calculation based solution to work.
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Re: Variable Calculation of Text and Length

Post by freddyp »

There is a logical error in the setup of the variables: Trimmed_by is not a Text (or a Number) but a Length. The value you want is not 400 but 400 mm. If you do it that way the calculation is correct.

The problem you have when not using a length is that the units of your input are unknown and this can lead to unpredictable results. Everybody will agree that 400 / 10 is 40, but if your preferences are set to millimeters something will move by 40 mm millimeters, but when the same Action List is used by somebody who has the units set to inches that same something will move by 40 inches. Defining Trimmed_by as a Length will show the currently active units which makes it clear to the user what is going to happen and should it be necessary to define the value in a different unit the user can simply type "1 in" and PitStop will convert it to 25.4mm.

For your cultural background: the "about 1/3" is actually 1/2.54.
loicaigon
Advanced member
Posts: 379
Joined: Wed Jul 10, 2013 10:22 am

Re: Variable Calculation of Text and Length

Post by loicaigon »

Hi Keith,

Is there a specific reason why you wouldn't use a length type data from the beginning? Setting the appropriate type typically prevents such issues.
So I would be very interested in knowing if there is a very strong reason to not use the length type in your case.

Loic
Keith@Studio1
Newbie
Posts: 2
Joined: Wed Sep 28, 2022 3:47 pm

Re: Variable Calculation of Text and Length

Post by Keith@Studio1 »

Hi Guys,

Firstly sorry for the late response prepress has been very busy...

Thanks for pointing me in the right direction I have my script sorted but wanted to go into a little bit of detail with my solution as it may help others.

@Loicaign - a valid point, the reason for this is you can,t refer to a length in a calculation, doing so errors out the script. I think the reason for this is that every length is appended with the default unit from the local setting, in my case this will be mm. So when you type 400 into a field it records 400#mm and as the #mm are text characters the calculation fails.
You can get it to work by setting the first variable to a number and setting the calculation to a length

@freddyp - Thanks I looked into this a bit further and I don't think its a previous users setting (in this instance I created the artwork and the units have always been millimetres). I think you are correct that it is calculating in inches but for a different reason.

If you search the for the maximum pdf size you get the following:
Per the ISO 32000 standard for PDF, the page dimension limit is 14,400 PDF units in each direction. A PDF unit is 1/72 of an inch
I think at a core level all calculations are worked at 1/72" (1pt) and then reconverted to local units.
So when you add 400 as a text or number variable and then convert it into a length calculation your actually getting 400pt =141.11111111mm
to convert the number from pt to mm you have to divide it by 0.3527

I have added the division into my calculation and all the results are correct now.

I will do a bit more testing and if I find any issues or conformation I will post my results

Thanks for your help

Keith
Post Reply