Area Macros


HaroonMalik
 Share

Go to solution Solved by Doug_N,

Recommended Posts

Helle Everyone!

I am using macros in my GFA summary sheet for my project. I am able to add or subtract multiple areas by using + or - symbols in the macro. Further, I am also able to multiply two values by using " * " symbol too. However, unfortunately the symbols "÷" or "/" do not work for a division operation. I will do appreciate if someone could help with the division of a couple of values in a macro.

Regards

Link to comment
Share on other sites

thanks for reply. i am using for example;

%$a=area%     Area of polyline say"a"

%$b=area%     Area of polyline say"b"

%$a+$b%     Total area of a+b

%$a+$b%     Total area of a+b

%$a*$b%     Multiplication of a&b

These all work, However

%$a/$b%     Division of a&b Does not

 

Link to comment
Share on other sites

Hummm....   I am not sure what is going on as it seems to work for me in X12.   You may need to post a test plan.

 

image.png

 

Actually the division works but the multiplication seems to be creating an issue.

 

Had to tweak the multiplication to get it to work without interference from the measurement class.

 

axb=%($a.to_f*$b.to_f).round%

 

image.thumb.png.885e1343fb35da677f5661d67d73d57f.png

  • Like 1
Link to comment
Share on other sites

Just now, HaroonMalik said:

Thank you Chopsaw for your reply. For me the multiplication works fine with asterik " * " sign. Unfortunately, division is not working in the same way by"/" or "÷" sign.

 

Give it a try with the same formatting as I used for the multiplication and see if that works.  Otherwise I would need to look at your setup or hope one of the macro gurus can spot the issue.

  • Like 1
Link to comment
Share on other sites

Thanks a lot Doug_N. It worked.....waao.

However, may i ask one more help?. The answer is in up to 7 places after decimal as shown in the image. I have rounded the answers that applies to the individual polygon but does not apply on the answer as shown. Appreciate your time and help.

1775910962_AreaCalc.thumb.jpg.adbc833d6b1b8b144bdd02a8584d4ec4.jpg

Link to comment
Share on other sites

Haroon,  I think it may just be a fluke that it worked this time.  I can't really explain it or fully understand it but it is likely the same reason that the division worked for me and not you and then the multiplication failed for me and not for you.

 

If you go back and take a look at my corrected formula, I think that is what you will need to use for consistent results.  I also showed how to correctly do the rounding you are now asking for.

  • Like 1
Link to comment
Share on other sites

Joe makes a good observation in his comment about variable types.  You can't divide an integer or floating value by a length or by an area.  But you can divide a length or area by any of the following: an area, a length, an integer or a floating point variable.

  • Like 1
Link to comment
Share on other sites

2 hours ago, Doug_N said:

Joe makes a good observation in his comment about variable types.  You can't divide an integer or floating value by a length or by an area.  But you can divide a length or area by any of the following: an area, a length, an integer or a floating point variable.

 

There are a few more things to consider:

  • volume(cu ft)/area(sq ft) = linear (inches)
  • volume(cu ft)*area(sq ft) = derived (nonsense)
  • volume(cu ft)/linear(inches) = area (sq ft)
  • volume(cu ft)/volume(cu ft) = ratio (unitless)
  •  
  • area(sq ft)/linear(inches) = linear (inches)
  • area(sq ft)*linear(inches) = volume (cu ft)
  • area(sq ft)/area(sq ft) = ratio (unitless)
  • area(sq ft)/volume(cu ft) = derived (nonsense)
  •  
  • area+/-linear = error, not allowed
  • area+/-volume = error, not allowed
  • volume+/-linear = error, not allowed
  •  
  • linear(inches)/area(sq ft) = derived (nonsense)
  • linear(inches)/volume(cu ft) = derived (nonsense)
  • There are probably a few more

Generally it's best to know what the units are and, if necessary convert to floating point values before the calculations.

  • Like 1
Link to comment
Share on other sites

29 minutes ago, Joe_Carrick said:

 

There are a few more things to consider:

  • volume(cu ft)/area(sq ft) = linear (inches)
  • volume(cu ft)*area(sq ft) = derived (nonsense)
  • volume(cu ft)/linear(inches) = area (sq ft)
  • volume(cu ft)/volume(cu ft) = ratio (unitless)
  •  
  • area(sq ft)/linear(inches) = linear (inches)
  • area(sq ft)*linear(inches) = volume (cu ft)
  • area(sq ft)/area(sq ft) = ratio (unitless)
  • area(sq ft)/volume(cu ft) = derived (nonsense)
  •  
  • area+/-linear = error, not allowed
  • area+/-volume = error, not allowed
  • volume+/-linear = error, not allowed
  •  
  • linear(inches)/area(sq ft) = derived (nonsense)
  • linear(inches)/volume(cu ft) = derived (nonsense)
  • There are probably a few more

Generally it's best to know what the units are and, if necessary convert to floating point values before the calculations.

Joe,

 

Have you considered doing a class on the use of Ruby in CA?   I bet lots of us would sign up for it.

  • Like 1
  • Upvote 2
Link to comment
Share on other sites

On 9/22/2023 at 12:45 PM, Chopsaw said:

Haroon,  I think it may just be a fluke that it worked this time.  I can't really explain it or fully understand it but it is likely the same reason that the division worked for me and not you and then the multiplication failed for me and not for you.

 

If you go back and take a look at my corrected formula, I think that is what you will need to use for consistent results.  I also showed how to correctly do the rounding you are now asking for.

Yes, you might be correct. The results often are not as expected at certain times. Similar method works the other day. I really appreciate valuable information and help offered by you all. Many Thanks

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share