Jump to content

Advanced measure


suriwaits

Recommended Posts

Hi,

I am in need of a lisp program to do the following

Sprayer irrigation design for rectangular/square areas/circular areas.

Step 1: Ask the user to enter shape, Rectangular or Circular

Step 2:. If entered area is Rectangular, use the following steps,

Step 3: Ask the user to enter preferred radius,

Step 4:

if entered value is

between 4 to 4.5m , program to insert block named 15-90 at each corner.

between 3 to 3.5m, program to insert block named 12-90 at each corner.

between 2 to 2.5m,program to insert block named 10-90 at each corner.

Step5

using measure command each section of polyline to be divided by the block name 15-180 if the user input in step 3 is 4-4.5m and length of section value to be taken from Step 3.

Similarly input from step 3 is between 3-3.5m then use block name 12-180,2-2.5m then use 10-180.

 

if input on step 1 is circular, skip step 4 and directly goto step 5.

 

There is something also to be added in next step, i know this is too much to ask at this stage.

 

Thanks in Advance.

Suriwaits.

spray.dwg

Link to comment
Share on other sites

  • Replies 47
  • Created
  • Last Reply

Top Posters In This Topic

  • suriwaits

    19

  • ymg3

    18

  • BIGAL

    6

  • pBe

    4

Top Posters In This Topic

Posted Images

What about internal sprinklers, shouldn't there be some ?

 

Pretty simple task just a lot of rules, the sprayer radius to me would be returned via a how many heads ? 1st try 4.5 is this ok then 3.5 then 2.5. Is the L different head radius to the W ? long skinny rectang ?

 

The object is auto as a Circle is not a Pline, rectang or square should not matter. Also the rectang should work on any angle. What about wierd shapes ?

 

Anyway I am sure such a thing exists wether its free or not is another question.

 

have a look at this http://www.softwarerepublic.com/raincad/raincad.aspx

Link to comment
Share on other sites

Dear Bigal,

 

I do the design manually, I cannot afford software like raincad, Land F/X, etc.

Most of this software has database about most of the products available in the market and works well with regular areas like square, rectangular and Circular areas basen on our input on sprinklers required.For irregular areas still we have to manually adjust the sprinklers by ourself.

 

When i do the design, i desire head to head coverage rather than how many sprinklers required. I can place strip nozzle manually (long skinny rectangles).

Yes, ofcourse i require full circle sprinklers. I don't want to bother you so much at this stage.

 

For circle, i always draw polyline on top of them, so the object will be always either line/arc/polyline.

 

Suriwaits.

What about internal sprinklers, shouldn't there be some ?

 

Pretty simple task just a lot of rules, the sprayer radius to me would be returned via a how many heads ? 1st try 4.5 is this ok then 3.5 then 2.5. Is the L different head radius to the W ? long skinny rectang ?

 

The object is auto as a Circle is not a Pline, rectang or square should not matter. Also the rectang should work on any angle. What about wierd shapes ?

 

Anyway I am sure such a thing exists wether its free or not is another question.

 

have a look at this http://www.softwarerepublic.com/raincad/raincad.aspx

Link to comment
Share on other sites

I still think need some rules the dwg is exact that spacing is 4.1 when this length is slightly less then what happens I expect just allow slight more overlap.

 

Its pretty easy in lisp to take the length of a side and work out spacing given ranges for the measure command and then add corner.

 

Your range would need to be more exact 4-4.5 3-3.5 what happens at 3.75 ?

 

Better to post a dwg with some true examples.

Link to comment
Share on other sites

Let us start with Half circular sprinkler only. Corner & Full Sprinklers will be dealt later.

find out the length of segment (X), divide this length by value entered in preferred radius (Y), if X/Y is fraction, round of this to nearest full number, eg if the Z=2.3, round of to 2(Z') & if Z=2.6 then round of to 3(Z').

Now divide X by new Z', Display Calculted radius ® is =X/Z' , ask the user whether to continue with the calculated radius®, if yes proceed to divide command and no of segments is Z', block name to be based on the range ie 15-180 for 4-4.5, 12-180 for 3-3.5m and 10-180 for 2-2.5m.

Example:

List line length X = 13m (to be calculated from drawing)

Preferred radius Y = 4.2 (User input)

no of segments Z =13/4.2=3.09

Z'=3 (round of value of Z)

Divide X/Z' = 4.333, Display this as "Calculate Radius is 4.33. Do you want to Proceed (Yes/No), if the input is "no" ask the user to "Enter new preferred radius". If the user input is "Yes", continue to divide (CAD Command) the object with Z' numbers of Block named 15-180.

Half Circle sprinkler.dwg

Link to comment
Share on other sites

Do you want someone to write all the code or just all the bits of how to make it work and you have a go yourself.

 

You have in the post above done the explanation of steps required. Only 1 question there is a difference between using a line and pline the example below is for a line

 

a simple start

(setq pickobj (entsel "\nPick line :"))
(setq stpt (cdr (assoc 10 (entget (car pickobj)))))
(setq endpt (cdr (assoc 11 (entget (car pickobj))))
(setq len (distance stpt endpt))
(setq rad (getreal "\nEnter desirable radius))
(setq howmany (/ len rad))
(Princ (fix howmany))

Link to comment
Share on other sites

Dear Bigal,

 

It would be great if could write full code for me as i don't know how to write a lisp :cry:.

I want the code to work on line, arc as well as pline. when it comes to pline it should consider the segment length between two vertex at a time. not the total length.

 

As far as i what i understood from your code posted above, it stops somewhere in the middle ie code stops at findingout the number of sprinkler required based on given radius, which will be most of the time will be in integer, alerting this number is not required. I want to round of the number to nearest full number and divide the length by full number. Now display the result as calculated radius is this much and contunue so on as detailed in my previous post.

 

Thanks

 

Suriwaits.

 

Do you want someone to write all the code or just all the bits of how to make it work and you have a go yourself.

 

You have in the post above done the explanation of steps required. Only 1 question there is a difference between using a line and pline the example below is for a line

Edited by suriwaits
Link to comment
Share on other sites

It would be great if could write full code for me as i don't know how to write a lisp

 

The people here at cadtutor volunteer their time so its not a go there and get what you want instantly I have a spare 5 mins at moment so will put a bit more code up as an example, I know Lee mac has a proper rounding routine will need that also.

 

If you want something real fast there is plenty of good people here who do work for a price.

Link to comment
Share on other sites

Suriwaits,

 

I've look a little bit at your problem.

 

Normally you want Head to Head sprinkling. Since we have a choice of 10' 12' or 15' radius only.

Not too sure, but I believe the desirable radius would be the one that minimize the remainder

of the distance / radius.

 

For your example Side length is 15.2 so,

 

(rem 15.2 4.57)   ==> 1.49
(rem 15.2 3.66)   ==> 0.56
(rem 15.2 3.048) ==> 3.008

 

So we get the minimum overspray at 3.66 or 12 feet.

 

If it works for every case you could get the proper type without having

to prompt for it.

 

ymg

Link to comment
Share on other sites

The people here at cadtutor volunteer their time so its not a go there and get what you want instantly I have a spare 5 mins at moment so will put a bit more code up as an example, I know Lee mac has a proper rounding routine will need that also.

 

If you want something real fast there is plenty of good people here who do work for a price.

 

 

I understand your efforts and Thanks for your time.

No hurry. I can wait forever.

Put some more code, i will try to make it up from there.

 

Thanks

Suriwaits

Link to comment
Share on other sites

There was a couple of typos I should test first but a bit more this works can be done better

 

(setq pickobj (entsel "\nPick line :"))
(setq stpt (cdr (assoc 10 (entget (car pickobj)))))
(setq endpt (cdr (assoc 11 (entget (car pickobj)))))
(setq len (distance stpt endpt))
(setq rad (getreal "\nEnter desirable radius"))
(setq howmany (/ len rad))
(setq frac (- howmany (fix howmany)))
(if (> frac 0.5000001)
(setq howmany (+ (fix howmany) 1))
(setq howmany (fix howmany))
)
(command "Divide" (car pickobj) "B" "001" "Y" howmany)
(princ "\nAll done") 

 

Next step is to put a reverse line so blocks face corret way everytime I will add maybe tomorrow if I have time

 

Try yourself to add insert at stpt and endpt

Link to comment
Share on other sites

Suriwaits,

 

I've look a little bit at your problem.

 

For your example Side length is 15.2 so,

 

(rem 15.2 4.57) ==> 1.49
(rem 15.2 3.66) ==> 0.56
(rem 15.2 3.048) ==> 3.008

 

So we get the minimum overspray at 3.66 or 12 feet.

 

If it works for every case you could get the proper type without having

to prompt for it.

 

ymg

 

You idea on on selecting sprinkler based on minium overspary is great. But the probelm is i have to adjust the sprinkler at 15.2/4=3.8m , which exceeds the range i have given (4-4.5m, 3-3.6m & 2.5-3.0m). Please Post your code on this, which will be useful for me for estimate purposes.

 

I will use your code on random length and check the results.

 

What if we could use the following,

for 4.57m, (4.57-1.49)/4.57=0.67,

for 3.66m, (3.66-0.56)/3.66=0.85,

for 3.048m, (3.048-3.008)/3.048=0.013, so that i can one more sprinkler instead of calculated one.

 

Real problem is most of the case, the sprinkler with minimum radius get selected.

Edited by suriwaits
Link to comment
Share on other sites

Suriwaits,

 

I've done a few checks and it does not work.

 

For example:

 

(defun sprktyp (d / minr tmp typ)
   (setq minr (rem d (* 15 0.3048)) typ 15)
   (if (< (setq tmp (rem d (* 12 0.3048))) minr) (setq minr tmp typ 12))
   (if (< (setq tmp (rem d (* 10 0.3048))) minr) (setq minr tmp typ 10))
   
   (list (/ d (+ (fix (/ d (* typ 0.3048))) 1)) (strcat (itoa typ) "-180"))
)

 

If I run it with 15.2 and 13.0 here are the results

 

$ (sprktyp 15.2)
(3.04 "12-180")
_$ (sprktyp 13.0)
(2.6 "10-180")

 

I will try something else.

 

ymg

Link to comment
Share on other sites

Here is a revised one:

 

(defun sprktyp (d / minr tmp typ)
   (setq  minr (- (* (+ (fix (/ d (* 15 0.3048))) 1) (* 15 0.3048)) d)    typ 15)
   (if (< (setq tmp (- (* (+ (fix (/ d (* 12 0.3048))) 1) (* 12 0.3048)) d)) minr) (setq minr tmp typ 12))
   (if (< (setq tmp (- (* (+ (fix (/ d (* 10 0.3048))) 1) (* 10 0.3048)) d)) minr) (setq minr tmp typ 10))
   
   (list (/ d (+ (fix (/ d (* typ 0.3048))) 1)) (strcat (itoa typ) "-180"))
)

 

results:

_$ (sprktyp 15.2)
(3.04 "10-180")
_$ (sprktyp 13.0)
(4.33333 "15-180")

 

Although it does not agree with your sample, the overspray is minimized.

 

ymg

Link to comment
Share on other sites

Dear YMG.

 

I think it will be very difficult when using fixed value.

 

It would be flexible, if you can use range (4-4.5, 3-3.5 & 2.5-2.9m) instead of using fixed radius like 15', 12', 10'.

 

 

for example for a 15' sprinkler, try 13', 13.5', 14' ,14.5' and 15'.

if none of the above fits then try 12' sprinkler with 10.5',11',11.5' & 12'.

10' sprinkler with 8.5',9',9.5,10'

 

Suriwaits,

 

I've done a few checks and it does not work.

 

For example:

 

I will try something else.

 

ymg

Edited by suriwaits
Link to comment
Share on other sites

Here is a revised one:

 

(defun sprktyp (d / minr tmp typ)
(setq minr (- (* (+ (fix (/ d (* 15 0.3048))) 1) (* 15 0.3048)) d) typ 15)
(if (< (setq tmp (- (* (+ (fix (/ d (* 12 0.3048))) 1) (* 12 0.3048)) d)) minr) (setq minr tmp typ 12))
(if (< (setq tmp (- (* (+ (fix (/ d (* 10 0.3048))) 1) (* 10 0.3048)) d)) minr) (setq minr tmp typ 10))

(list (/ d (+ (fix (/ d (* typ 0.3048))) 1)) (strcat (itoa typ) "-180"))
)

 

results:

_$ (sprktyp 15.2)
(3.04 "10-180")
_$ (sprktyp 13.0)
(4.33333 "15-180")

 

Although it does not agree with your sample, the overspray is minimized.

 

ymg

 

Looks great,

 

but i don't know how to check this in AutoCAD.

Link to comment
Share on other sites

Suriwaits,

 

Try this, No error checking and No optimization. Circular Zone not implemented yet.

 

ymg

 

(defun round (x) (if (>= (- x (fix x)) 0.5) (1+ (fix x)) (fix x)))
(defun dtr (a) (* pi (/ a 180.0)))
(defun rtd (a) (/ (* a 180.0) pi))
 

;;; listpol   by Gille Chanteau                                               ;
;;; Returns the vertices list of any type of polyline (WCS coordinates)       ;
;;;                                                                           ;
;;; Argument                                                                  ;
;;; en, a polyline (ename or vla-object)                                      ;

(defun listpol (en / i p l)  
 (setq i (+ (vlax-curve-getEndParam en) (if (vlax-curve-IsClosed en) 1 0))))
 (while (setq p (vlax-curve-getPointAtParam en (setq i (1- i))))
     (setq l (cons (trans p 0 1 ) l))
 )
)

(defun sprktyp (d / minr tmp typ)
   (setq  minr (- (* (+ (fix (/ d (* 15 0.3048))) 1) (* 15 0.3048)) d)    typ 15)
   (if (< (setq tmp (- (* (+ (fix (/ d (* 12 0.3048))) 1) (* 12 0.3048)) d)) minr) (setq minr tmp typ 12))
   (if (< (setq tmp (- (* (+ (fix (/ d (* 10 0.3048))) 1) (* 10 0.3048)) d)) minr) (setq minr tmp typ 10))    
   (list (/ d (+ (fix (/ d (* typ 0.3048))) 1)) (strcat (itoa typ) "-180"))
)

(defun c:spr ( / a cb d d1 d2 enl n oldsnap p1 pl s1b s2b ss)
 (setq oldsnap (getvar 'OSMODE))
 (setvar 'OSMODE 0)
 (prompt "\nSelect The Zone To Cover With Sprinklers:")
 (if (setq ss (ssget "_:S" '((-4 . "<or")(0 . "*POLYLINE")(0 . "CIRCLE")(-4 . "or>"))))
    (progn
       (setq enl (entget (ssname ss 0)))
       (cond
           ((= (cdr (assoc 0 enl)) "CIRCLE") (princ "\nNot Implemented Yet."))
           (t (setq pl (listpol (ssname ss 0))
                    p1 (car pl)
                    pl (cdr pl)
                    d1 (distance p1 (car  pl))
                    d2 (distance (car pl) (cadr pl))
                   s1b (sprktyp d1)
                   s2b (sprktyp d2)
                    cb (strcat (itoa (max (atoi (cadr s1b)) (atoi (cadr s2b)))) "-90")
               )
               (repeat 2
                  (vl-cmdf "_INSERT" cb p1 "" "" (rtd (setq a (angle p1 (car pl)))))
                  (setq n 1)                 
                  (while (< (setq d (* n (car s1b))) d1)                       
                      (vl-cmdf "_INSERT" (cadr s1b) (polar p1 a d) "" "" (rtd a))
                      (setq n (1+ n))
                  )
                  (setq p1 (car pl) pl (cdr pl))
                  (vl-cmdf "_INSERT" cb p1 "" "" (rtd (setq a (angle p1 (car pl)))))
                  (setq n 1)                 
                  (while (< (setq d (* n (car s2b))) d2)                       
                      (vl-cmdf "_INSERT" (cadr s2b) (polar p1 a d) "" "" (rtd a))
                      (setq n (1+ n))
                  )
                  (setq p1 (car pl) pl (cdr pl))
               ) 
           )          
                
       )
    )
 )
 (setvar 'OSMODE oldsnap)
 (princ)
)       

Edited by ymg3
Link to comment
Share on other sites

Only thing I would change YMG is as below saves lots of typing

 

(setq s15 (* 15.0 0.3048)) or (setq s15 4.572) 
(setq s10 3.048)
(setq s12 (* 12.0 0.3048)) or (setq s12 3.6576)
; note be careful * 15 0.3048 can return a integer * 15.0 0.3048 forces real answer

 

Just a general as a an engineer working in metric we would not use 3.048 we would adopt 3.0 3.6 & 4.5 and use metric sprinkler hydraulic design formulas

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...