Run a calculation when clicking on something

Run a calculation when clicking on something

Anonymous
Not applicable
653 Views
7 Replies
Message 1 of 8

Run a calculation when clicking on something

Anonymous
Not applicable

Hello all, this is my first post here and I have a question.  I am wondering if there is a way to set up autocad to run a calculation when I click on a closed polygon.  For instance, I do irrigation design in autocad without using civil 3d or any other add ons.  Whenever I draw an area that will be drip irrigation its always a closed polygon.  I would like to be able to click on the polygon and have autocad generate the gallons per minute based on input I give autocad on emitter spacing, row spacing, area of the polygon, and water volume of each emitter.  Currently I have an excel spreadsheet set up that I change the values of those fields and just type in the square footage of the polygon in autocad.  But if I could come up with something in autocad it would make things much faster.  Thanks for any input!

0 Likes
654 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

If the emitters are always in rectangular grids, the emitter spacing [within a row, I presume] x the row spacing would give the area each emitter covers, and the area of the polygon could be divided by that to give a pretty close quantity of emitters, which could then be multiplied by the volume of each, easily enough.  That wouldn't necessarily give an exact  number of emitters, because irregular shapes with angled or curved edges may have some positionings much closer than typical spacing to the edges [i.e. such an emitter covers less of the footprint], which might be omitted in an actual installation.  And exactly where the grid itself "falls" in relation to the boundary edges would affect the quantity, e.g.:

EMITTERS.PNG

[The one on the right is the result you'd get from my suggestion, in a "clean" situation like this.]  The larger the area, the less the calculated result is likely to vary from an actual layout quantity [I think].  Would such a simple calculation be close enough for your purposes?

Kent Cooper, AIA
0 Likes
Message 3 of 8

Anonymous
Not applicable

Thanks for the response.  They are rarely in perfect rectangles or squares.  And it isn't necessary the number of emitters that I am looking for, its the final amount of water put out per minute in that size of an area.  

 

For example, lets say an area is 256 square feet.  The row spacing is 18" and the emitter spacing is 12".  The output of each emitter is .77 gallons per hour.  The formula is (256*12/18*.77/60)  The answer is 2.19 gallons per minute.  What I'd like is to be able to click on the polygon and immediately it places in text "2.19" in the middle of that polygon.  

0 Likes
Message 4 of 8

Anonymous
Not applicable

This could be done in either VBA or LISP, but (I think) you would have to launch the code 1st and then click on the polyline...

@Kent1Cooperis a whiz at that stuff, if he can't figure it out pretty quick, try posting >here< or >here<

 

0 Likes
Message 5 of 8

Anonymous
Not applicable

I'm fine with either way of having to do it.  I just have no experience in coding and was thought it could be done but wasn't sure.  Right now its just a tedious and drawn out task that I'd love to be able to make more streamlined.  

0 Likes
Message 6 of 8

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

For example, lets say an area is 256 square feet.  The row spacing is 18" and the emitter spacing is 12".  The output of each emitter is .77 gallons per hour.  The formula is (256*12/18*.77/60)  The answer is 2.19 gallons per minute.  ....  


 

That's not really the right way to express the equation, but happens to work only because the emitter spacing is 12", i.e. a foot -- your area is in square feet, but your spacings are in inches.  The 12/18 happens to be the inverse of 1.5, which is the number of square feet served by each emitter, only because of the 12.  But with the same ratio  between spacings, whatever they are, for example, with a row spacing of 36"  and an emitter spacing of 24", you get the same answer, but it's way off -- there are only a quarter as many emitters!

 

The formula should express all in the same units, such as (256*1.0/1.5*.77/60) [with the spacings also in feet as the area is in square feet].

 

But yes, that can be automated pretty easily -- not at the moment, but I may take a shot at it later if someone else doesn't jump in.

Kent Cooper, AIA
0 Likes
Message 7 of 8

Anonymous
Not applicable

Well I will start by saying math is not my strong suit. So however you want to explain it is fine. I just know it all works in my head. I appreciate all the help and if someone were to write a code at some point I’d be extremely grateful. 

0 Likes
Message 8 of 8

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:
....The formula should express all in the same units, such as (256*1.0/1.5*.77/60) ....

Actually, that should be:

 

256 / (1.0 * 1.5) * .77 / 60

 

What I had before was not enough of a change -- it gives the same incorrect result with different spacings at the same ratio.

Kent Cooper, AIA
0 Likes