[To...] Posted August 1 Share Posted August 1 I've created a Max Result and a Min Result for a set of Y values. I'm using a Result Element to calculate the range between the Max and Min Results. As long as the Max is positive and the Min is negative, or both values are positive, the formula, "getActual("Maximum_Pocket Locations").actual- getActual("Minimum_Pocket Locations").actual" works great, but if both values are negative, i.e. Max -.001 and Min -.0015, etc., then the 2 values add. How would I prevent this? Link to comment Share on other sites More sharing options...
[Cl...] Posted August 1 Share Posted August 1 Not sure where you'd place it in the formula, but the "ABS" should work here. Link to comment Share on other sites More sharing options...
[Ha...] Posted August 1 Share Posted August 1 (edited) If both the maximum and minimum results are negative like in the example, the resulting range should come out as max-min=(-0.001)-(-0.0015)=0.0005. The subtraction sign should be distributing into the negative minimum result, turning it into a positive number in the expression. On that note, if you want to involve the absolute value function, I would apply it to each result, then apply it to the difference. Something like the following below. abs(abs(getActual("Maximum_Pocket Locations").actual)- abs(getActual("Minimum_Pocket Locations").actual)) Edited August 1 Re-framing the distribution explanation. 1 Link to comment Share on other sites More sharing options...
[To...] Posted August 1 Author Share Posted August 1 Please sign in to view this username. I tried that but I when I tested it, I used abs(-0.0010 - 0.0015) which produces 0.0025. Then I realized I needed to do this abs(-0.001 -(-0.0015)) DOH abs("getActual("Maximum_Pocket Locations").actual- getActual("Minimum_Pocket Locations").actual) It goes in the Result Element formula field. Thanks for making think harder. Link to comment Share on other sites More sharing options...
[To...] Posted August 1 Author Share Posted August 1 (edited) Please sign in to view this quote. Actually, using abs on both messes up the formula if Max is positive and Min is Negative. Edited August 1 Link to comment Share on other sites More sharing options...
[Ha...] Posted August 1 Share Posted August 1 You're right. I went overboard on the expression. 1 Link to comment Share on other sites More sharing options...
[Ni...] Posted August 1 Share Posted August 1 Please sign in to view this quote. Ran into this same issue, except in a MS excel table with deviation results from Calypso. I was comparing deviation values on features and needed to calculate to total deviation difference between two features. I ended up asking ChatGPT to produce a formula for me to address the issue you are having, the bot gave me what I needed. 1 Link to comment Share on other sites More sharing options...
[Ri...] Posted August 1 Share Posted August 1 I think it should just be: val1 = 5 val2 = -10 absrange = abs(val1-val2) Link to comment Share on other sites More sharing options...
[Ri...] Posted August 1 Share Posted August 1 2 Link to comment Share on other sites More sharing options...
[Ra...] Posted August 1 Share Posted August 1 This is probably dumb, but once you grab the max and min y values, create a max point using y value max, and the min point using the y value min. Then create a line using said points and report the length. 1 Link to comment Share on other sites More sharing options...
[Ma...] Posted August 1 Share Posted August 1 MAX(getActual("Maximum_Pocket Locations").actual,getActual("Minimum_Pocket Locations").actual)-MIN(getActual("Maximum_Pocket Locations").actual,getActual("Minimum_Pocket Locations").actual) Or something similar wouldn't work? Link to comment Share on other sites More sharing options...
[Ma...] Posted August 2 Share Posted August 2 (edited) Write a conditional branching statement that tests the value as negative or positive. If you have the negative values *-1 to change to positive values then output the result. Edited August 2 Link to comment Share on other sites More sharing options...
[To...] Posted August 4 Author Share Posted August 4 (edited) Richard, in all of your test values, you inadvertently filled the Max (absolute) value as val1, so when you calculated the abs(val1 - val2), the math always works. In the first example val1 = -10 and val2 = -5. However, -5 is greater than -10. I think Mark might be onto something. Edited August 4 Link to comment Share on other sites More sharing options...
[Ch...] Posted August 4 Share Posted August 4 I have to calculate things like this often, I think conditional branch is necessary and safest way, however I would recommend using Please sign in to view this username. 's suggestion as well , creating theoretical points, and output the distance of this line. Link to comment Share on other sites More sharing options...
[Ri...] Posted August 4 Share Posted August 4 Please sign in to view this quote. Tom, There are no issues swapping which one is val1 and which one is val2. 2 Link to comment Share on other sites More sharing options...
[Ma...] Posted August 6 Share Posted August 6 here is 2 diameters and we are wanting the distance, one diameter is in the negative Y axis and one in the positive Y axis. The first test, we need to check if Circle1 is the diameter that we need to convert to a positive value. The next test is checking if Circle2 is the diameter we need to change to a positive value. Var1 = getActual("Circle1").y Var2 = getActual("Circle2").y if Var1<0.000 then Var3 = abs(Var1) Dist = Var3+ Var2 endif if Var2<0.000 then Var4 = abs(Var2) Dist = Var1+ Var4 endif In the Result Element add Dist to the formula 1 Link to comment Share on other sites More sharing options...
[Ma...] Posted August 6 Share Posted August 6 Please sign in to view this quote. Sorry for this negative comment, but that is not a good code to be honest. Please sign in to view this username. posted a valid code - one-liner to be exact - why a such complicated approach? Link to comment Share on other sites More sharing options...
[Ma...] Posted August 6 Share Posted August 6 (edited) Well, it works. 🤷♂️ Also Richard’s put in the known value. This one will capture the actual values. You can save this one as a macro too. Edited August 6 Link to comment Share on other sites More sharing options...
[Ri...] Posted Monday at 06:59 PM Share Posted Monday at 06:59 PM In the past, I have created alignments that will produce numbers that are consistently either negative or positive to avoid PCM where some CMM's do not have PCM. This makes math statements easier with basic PCM and result elements. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in