Jump to content

Recommended Posts

Posted

BIGAL,

 

You are right. But as a former surveyor we would use (meters= feet * 0.3048 ) and (feet = meters / 0.3048 ).

 

I guess old habit die hard.

 

ymg

  • 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

Posted

Suriwaits, BIGAL.

 

Attached is an Excel Sheet giving the amount of Overspray at the Corner,

over the range 5 meters to 30 meters.

 

There are some problem Zones due to the limited choice of Spray Radius.

 

ymg

Sprinkler.xlsx

Posted

Please find attached excel. Could you please alter you code as per attached. i tried your code, but it is giving some error msg. i don't know how to debug it.

 

This might work well in most cases, but if we have a lengthy strip like 40m length x 2.5m wide then as per my calculation it will select 15-180, which is wrong. I think we can figure this out later.

 

Suriwaits, BIGAL.

 

Attached is an Excel Sheet giving the amount of Overspray at the Corner,

over the range 5 meters to 30 meters.

 

There are some problem Zones due to the limited choice of Spray Radius.

 

ymg

Sprinkler.xlsx

Posted

Suriwaits,

 

Right now the formula does not let Underspray happen.

 

Would it be acceptable if instead of always overshooting the neighbour,

we undershoot. This is what I call Underspray.

 

If acceptable I'll modify the function tomorrow.

 

ymg

Posted

Suriwaits,

 

Here is the routine modified to allow for underspray.

 

Better, but there are still Zone where the overspray/underspray will go to 1.5 meter.

 

I've added a test function, if you issue TEST as a command, a table over the range 5m. to 40 m. will be generated and printed on the text screen.

 

(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))
 )
)

;; sprktyp                                                                    ;
;;                                                                            ;
;; Argument: d  Length of Side To Install Sprinklers.                         ;
;;   Return: A list (Spacing "Type" HDnum Overspray)                          ;

(defun sprktyp (d / hdnum hdtyp head headl ovspr ovtmp radius rtn)
   (setq headl '((4.572 . "15-180")(3.658 . "12-180")(3.048 . "10-180"))
         ovspr 99999
   )
   (foreach head headl
      (setq  radius (car head)
              hdtyp (cdr head)
              hdnum (round (/ d radius))
              ovtmp (abs (- (* hdnum radius) d))
            spacing (/ d hdnum)
      )
      (if (< ovtmp ovspr)
         (setq ovspr ovtmp
                 rtn (list spacing hdtyp hdnum ovspr)
         )
      )
   )
   rtn
)   

(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)
)

(defun c:test ()
  (setq d 5.0)
  (textscr)
  (princ "\nD  \tSpc\tTYP\tHD#\t OVSpray")   
  (while (< d 40.1)
    (setq typ (sprktyp d))    
    (princ (strcat "\n" (rtos d 2 1) "\t" (rtos (car typ) 2 2) "\t" (cadr typ) "\t" (itoa (caddr typ)) "\t" (rtos (cadddr typ) 2 2)))
    (setq d (+ d 0.1))
  )
  (princ)
)  

Posted (edited)

Thanks. Apppreciate your efforts.

 

Command: Spr not working, it just ask the user to select object. after that nothing, command just ends.

 

Command: test list the table for various distance. As the distance goes beyond 20m, 15' will be the easy choice in practical but your calculation select for 10-180, then 12-180 and 15-180 in sequence and then changes again.

 

i think you did not notice my calc in the excel file i have attached before, so i am attaching it again. It consists simple mathematical function. I guess we can implement the same funcion in lisp. I don't mind inputting radius rather than automatically selecting the radius, it will give the user more control over selection.

 

Please note that 15', 12', 10' are the max radius limit i want to use, this can be reduced to to a 25% max. by manufacturer recommendation. That is the reason i have the limit like 4-4.5m, 3.1-3.6m, 2.5-3.0m.

 

This is what i am requesting, forget about what i asked earlier.

 

1. Ask the user to select a line or poly line, and enter the radius required. if the entered radius in not in the range of 4-4.5,3.1-3.6, 2.5-3.0. Give error message "Not in range. Try Smaller Series Nozzles manually"

2. Ask the user to select (Exact spacing / Best Fit),

for exact spacing use measure command with the radius entered

for best fit, use divide command by calculating no of segments based on calc in the excel attached.

(Block selection, if input radius is between 4-4.5 (15-180), 3.1-3.6 (12-180) & 2.5-3.0 (10-180))

 

Suriwaits,

 

Here is the routine modified to allow for underspray.

 

Better, but there are still Zone where the overspray/underspray will go to 1.5 meter.

 

I've added a test function, if you issue TEST as a command, a table over the range 5m. to 40 m. will be generated and printed on the text screen.

 

Sprinkler.xlsx

Edited by suriwaits
Posted (edited)

Suriwaits,

 

I've just tested taken the code from the page and it works for me.

 

Of course you need a drawing with your block already defined.

 

 

I did notice your calculations.

 

Please refrain from quoting the whole previous post this is wasteful,

and we can refer to the previous post easily.

 

If I test for 90 meters distance:

 

(sprktyp 90.0)
(4.5 "15-180" 20 1.44)

 

This means 4.5 meters spacing between heads, Type 15-180 is selected,

20 spaces on this side, Overspray/Underspray is 1.44 meters.

 

This is what i am requesting, forget about what i asked earlier.

 

Your tone seems a little aggressive there.

 

ymg

sprinklers.png

sprinkler.dwg

sprinkler.LSP

Edited by ymg3
Posted

Dear YMG.

 

Sorry for my bad english. I did not intend to be aggressive. i guess i can not differentiate emotion while writing something in english.

 

I have tested you code in a drawing which contains block 15-180, 12-180, 10-180. I am using Autocad 2010. But it is not working for me.

Posted

I tested on a rectangle. it is working. Sorry i have tried in a line before.

Posted

Suriwaits,

 

I am not Gille, I am ymg

 

As told before there is not much error trapping in the routine.

 

To work it must be a polyline and be drawn from Lower Left to Upper Right.

Once we are OK with the head selection we can add more error trapping and

let the routine works no matter the orientation.

 

First test it and let me know.

 

ymg

Posted

Great.

Thanks for the excellent lisp.

 

I will test on some random cases and may be i require small correction.

 

Suriwaits

Posted

suriwaits,

 

Here I have added the Circular Zone.

 

(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))
 )
)

;; sprktyp                                                                    ;
;;                                                                            ;
;; Argument: d  Length of Side To Install Sprinklers.                         ;
;;   Return: A list (Spacing "Type" HDnum Overspray)                          ;

(defun sprktyp (d / hdnum hdtyp head headl ovspr ovtmp radius rtn)
   (setq headl '((4.572 . "15-180")(3.658 . "12-180")(3.048 . "10-180"))
         ovspr 99999
   )
   (foreach head headl
      (setq  radius (car head)
              hdtyp (cdr head)
              hdnum (round (/ d radius))
              ovtmp (abs (- (* hdnum radius) d))
            spacing (/ d hdnum)
      )
      (if (< ovtmp ovspr)
         (setq ovspr ovtmp
                 rtn (list spacing hdtyp hdnum ovspr)
         )
      )
   )
   rtn
)   

(defun c:spr ( / a cb d d1 d2 enl n oldsnap p1  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") (setq pc (cdr (assoc 10 enl))
                                                   rd (cdr (assoc 40 enl))
                                                perim (* 2 pi rd)
                                                  typ (sprktyp perim)
                                                  ang (/ (* 2 pi) (caddr typ))
                                                   p1 (polar pc 0 rd)
                                                    a 0
                                              )                                               
                                              (repeat (caddr typ)
                                                  (vl-cmdf "_INSERT" (cadr typ) (polar pc a rd) "" "" (+ (rtd a) 90))
                                                  (setq a (+ a ang))
                                              )  
           )
           (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)
)

(defun c:test (/ d typ)
  (setq d 5.0)
  (textscr)
  (princ "\nD  \tSpc\tTYP\tHD#\t OVSpray")   
  (while (< d 40.1)
    (setq typ (sprktyp d))    
    (princ (strcat "\n" (rtos d 2 1) "\t" (rtos (car typ) 2 2) "\t" (cadr typ) "\t" (itoa (caddr typ)) "\t" (rtos (cadddr typ) 2 2)))
    (setq d (+ d 0.1))
  )
  (princ)
)

Posted
suriwaits,

 

Here I have added the Circular Zone.

 

Works very well.

It would be great, you could please alter the code instead of Over spray, under spray upto 20%, eg 10' max radius is 3.1 and min radius is (3.1-0.2*3.1)=2.48, for 12' max radius is 3.7 and min radius is 3.11, similarly for 15', max radius is 4.6 and min is 3.71.

 

Also, for the rectangular area, i would like the code to compare to between vertical direction and horizontal direction, select minimum of these two (eg i have 42x3.2m, as code select 15-180 for 42m side, 12-90 for 3.2m side instead i want to compare which is min, place 12series sprinklers with the distance as required for 12 series). i don't know this is practically possible in all cases.

 

Thanks

 

Suriwaits

Posted

suriwaits,

 

I've been trying to explain to you that your intervals do not work.

 

What do you do when none of the Heads can meet your criteria ?

 

Look at the attaced Excel Sheet and you will see that there are many places where this happen

because of the limited choice of radius.

 

ymg

sprinkler2.xlsx

Posted
...

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

 

... I've been trying to explain to you that your intervals do not work.

What do you do when none of the Heads can meet your criteria ?...

 

Wondering myself when the OP will realize that condition, and that is the item I've been waiting on all this time ymg

Posted

pBe,

 

I suppose that when we don't meet the criteria, we don't irrigate. :?

 

ymg

Posted

I suppose that when we don't meet the criteria, we don't irrigate. :?

 

:rofl:. Hope the OP would take into account that missing bit of information to close the deal.

Posted
Wondering myself when the OP will realize that condition, and that is the item I've been waiting on all this time ymg

 

I realized the reason you were trying to explain. That's why i have changed the range 2.48-3.1 for 10', 3.101 to 3.7 for 12' and 3.701 to 4.6 for 15' in Post #33. With this new condition i think it will work for almost for all except lines with less than 2.48m length.

 

The reason i am sticking with this is because you cannot a adjust 15' sprinkler to 17' in field, 12' to 13' . Since it is the max. radius. But you can reduce to 20% of max radius.

Posted

suriwaits,

 

Look at the Excel sheet.

 

I gave you the minimum for all types of heads.

 

The spread goes to as high as 1.52 meter.

 

What does that tell you ?

 

Now if you want to change it for your range be my guest!

 

ymg

Posted (edited)
suriwaits,

 

Look at the Excel sheet.

The spread goes to as high as 1.52 meter

ymg

 

 

Sorry for being such a pain. Ur concept of selecting sprinkler is good. But when the segment length exceeds 24m. any length can be divided into multiples of 15' (3.7-4.6m), hence no need to select small radius even though which is more perfect match as per your calculation.

 

eg. for 25m, 6 segments, radius 4.17, 15-180

26m, 7 segments, radius 3.71, 15-180

27m, 7 segments, radius 3.86, 15-180

28m, 7 segments, radius 4, 15-180

 

Please look at the excel i have attached.

 

My first preference is 15' (so i try 3.701)

find no of segments by calcuating quotient (segment length, 3.701),

find Remainder by calcualting Mod (segment length, 3.701)

new radius is 3.701+(rem/3.701) , if this is less than 4.6, go ahead with 15-180. other wise try with 12'

find no of segments by calcuating quotient (segment length, 3.101),

find Reminder by calcualting Mod(segment length, 3.101)

new radius is 3.101+(rem/3.101) , if result is less than 3.7, go ahead with 12-180.

otherwise try with 10'

find Reminder by calcualting Mod(segment length, 2.4)

new radius is 2.48+(rem/2.4), if result is less than 3.1, go ahead with 10-180.

otherwise

give alert msg " not in range", and exit the command.

 

 

 

I googled & found some equivalenet lisp (?) function for this. But i don't know how to use this in code. Please help me on this.

 

Function: quotient x y Divide integer x by integer y; return an integer quotient and discard the remainder. If x or y is negative, the direction of rounding is undefined.

 

Function: idiv x y Perform an integer division; if x and y are both nonnegative integers, this uses the quotient function, otherwise it computes `floor(x/y)'. Thus the result is well-defined but slower than for quotient.

 

Function: imod x y Divide integer x by integer y; return the integer remainder and discard the quotient. Like quotient, this works only for integer arguments and is not well-defined for negative arguments. For a more well-defined result, use `(% x y)'.

 

Function: idivmod x y Divide integer x by integer y; return a cons cell whose car is `(quotient x y)' and whose cdr is `(imod x y)'.

calc.xlsx

Edited by suriwaits

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...