Author Topic: Swamped again!  (Read 2682 times)

0 Members and 1 Guest are viewing this topic.

Water Bear

  • Guest
Swamped again!
« on: March 09, 2004, 11:48:00 AM »
I think that the problem I'm having here may be about creating a list...I'm trying to do a simple ratio calculation but I can't seem to get it set up. Most of the time we have to figure out a neck size when a duct splits, usually we know the CFMs so we use that to calc required neck size...but sometimes (alot of times) we don't know the volume of the main (usually in existing systems) so I use a proportional sizing. I get the area of a branch, then the area of ALL branches, divide the branch area by the total area of all and multiply this by the main size
I can't get the structure
Code: [Select]

(defun calc_neck () ;/ ans total branch main neck wid dep area tally)
  (initget 1 "P C")
  (setq
    ans (getkword
 "\nSelect which method to use [Cfms/Proportional]:"
 )
    )
  (cond
    ((= ans "C")
     (setq total  (getreal "\nEnter total CFMS:")
  branch (getreal "\nEnter CFMS for this branch:")
  main  (getreal "\nEnter duct size of main:")
  )
     (setq neck (* (/ branch total) main))
     (prompt (strcat "\nThe neck will be " (rtos neck 5 4) "\""))
     )
    ((= ans "P")
     (setq main  (getreal "\nEnter Width of Main:")
  wid  (getreal "\nEnter target branch Width:")
  dep  (getreal "\nEnter target branch Depth:")
  target (* wid dep)
  loop  t
  )
     (while loop
       (setq wid (getreal "\nEnter next branch Width:")
    dep (getreal "\nEnter next branch Depth:")
    )
       (if (or (null wid) (null dep))
(setq loop nil)
)
       (setq area  (* wid dep)
    tally (+ target area)
    neck  (* (/ target tally) main)
    )
       )
     )
    )
  (prompt (strcat "\nThe neck will be " (rtos neck 5 4) "\""))
  (princ)
  )
(princ)

daron

  • Guest
Swamped again!
« Reply #1 on: March 09, 2004, 12:49:21 PM »
I don't know if this is in-line with what you're looking for, but I adjusted the Proportional area to do what I think might be what you're looking for. If I'm off the mark, baybe it'll give you some ideas, if I'm on the mark, great. I also took the liberty to adjust your first initget. You can set it back if you prefer. Here:
Code: [Select]
(defun calc_neck () ;/ ans total branch main neck wid dep area tally)
     (initget "Proportional Cfms")
     (setq
 ans (getkword
  "\nSelect which method to use [<C>fms/Proportional]:"
     )
     )
     (cond
 ((or (= ans "Cfms") (= ans nil))
  (setq total (getreal "\nEnter total CFMS:")
branch (getreal "\nEnter CFMS for this branch:")
main (getreal "\nEnter duct size of main:")
  )
  (setq neck (* (/ branch total) main))
  (prompt (strcat "\nThe neck will be " (rtos neck 5 4) "\""))
 )
 ((= ans "Proportional")
  (setq main (getreal "\nEnter Width of Main:")
wid (getreal "\nEnter target branch Width:")
dep (getreal "\nEnter target branch Depth:")
target (* wid dep)
loop t
  )
  (while loop
(initget 2)
(setq wid (getreal "\nEnter next branch Width:"))
(if (= wid nil)
   (setq loop nil)
   (progn
(initget 2)
(setq dep (getreal "\nEnter next branch Depth:"))
(if (= dep nil)
    (setq loop nil)
    (setq area  (* wid dep)
  tally (+ target area)
  neck  (* (/ target tally) main)
  )
    )
)
   )
     (prompt (strcat "\nThe neck will be " (rtos neck 5 4) "\""))
  )
 )
     )
     (princ)
)

Water Bear

  • Guest
Swamped again!
« Reply #2 on: March 09, 2004, 04:55:18 PM »
Good try Daron..but it still didn't work :cry:
maybe this will help here's what I'm trying to do
Quote
1- get the main size
2-get target branch width
3-get target branch depth
4-calc the area and save to A

5-get next branch width
6-get next branch depth
7-calc area and save as B

8-get next branch width
9-get next branch depth
10-calc area and add it to B

11-repeat 8,9,10 until a nil is entered
12-then add A to B call it C
13-divide A by C and multiply by #1

daron

  • Guest
Swamped again!
« Reply #3 on: March 09, 2004, 05:13:41 PM »
I'm still not sure what you need, but it sounds like somewhere between steps 5-10 you need to (setq area (+ area B))? Whatever B is? You don't need to rename it to C, that way. It'll just keep adding it up and retaining its value.

daron

  • Guest
Swamped again!
« Reply #4 on: March 09, 2004, 05:17:02 PM »
Here's a simple add/multiply routine I wrote a while ago and have begun updating recently. It could still use work, but it might give you an idea of what I'm talking about.
Code: [Select]
(defun c:add ()
     (setq getext   (ssget (list (cons 0 "text")))
  cnt    0
  total    nil
  mathtype nil
     )
     (while (/= "TEXT"
(cdr (assoc 0
   (entget (setq addup
     (car (entsel
"\nSelect text object to calculate to: "
  )
     )
   )
   )
    )
)
   )
 (prompt "\nText object not selected. ")
     )
     (repeat (sslength getext)
 (setq ename (ssname getext cnt)
elist (entget ename)
tvalue (cdr (assoc 1 elist))
 ;"x" set mode for multiplication
value (atoi tvalue)
 ;converted value to associated number or 0 if tvalue is x
cvalue (itoa value)
counter 1
cnt (1+ cnt)
 )
 (if (= tvalue cvalue) ;then multiply, else add
      (setq total (apply 'append (list total (list value))))
      (setq mathtype (apply 'append
    (list mathtype (list tvalue))
     )
      )
 )
     )
     (if (and (listp mathtype)
     (/= mathtype nil)
)
 (setq mathtype (nth 0 (member '"X" mathtype)))
(setq mathtype "+")
     )
     (setq coll-1st (nth 0 total)
  rem-1st  (cool total 0)
     )
     (cond ((= (read mathtype) (read "x"))
   (foreach item rem-1st
(setq coll-1st (* coll-1st item))
   )
  )
  ((/= (read mathtype) (read "x"))
   (foreach item rem-1st
(setq coll-1st (+ coll-1st item))
   )
  )
     )
     (setq tlist (entget addup)
  oval (cdr (assoc 1 tlist))
     )
     (entmod
 (subst (cons 1 (rtos coll-1st 2 0)) (cons 1 oval) tlist)
     )
     (entupd addup)
     (princ)
)

Water Bear

  • Guest
Swamped again!
« Reply #5 on: March 09, 2004, 06:10:02 PM »
Thanks Daron, I figured it out...
Code: [Select]
(defun calc_neck (/ ans total branch main neck wid dep A B)
  (initget "P C")
  (setq
    ans (getkword
 "\nSelect which method to use [<C>fms/Proportional]:"
 )
    )
  (cond
    ((or (= ans "C") (= ans nil))
     (setq total  (getreal "\nEnter total CFMS:")
  branch (getreal "\nEnter CFMS for this branch:")
  main  (getreal "\nEnter duct size of main:")
  )
     (setq neck (* (/ branch total) main))
     (prompt (strcat "\nThe neck will be " (rtos neck 5 4) "\""))
     )
    ((= ans "P")
     (setq main (getreal "\nEnter Width of Main:")
  wid (getreal "\nEnter target branch Width:")
  dep (getreal "\nEnter target branch Depth:")
  A (* wid dep)
  B 0.0
  loop t
  )
     (while loop
       (initget 2)
       (setq wid (getreal "\nEnter next branch Width:"))
       (if (= wid nil)
(setq loop nil)
(progn
  (initget 2)
  (setq dep (getreal "\nEnter next branch Depth:"))
  (if (= dep nil)
    (setq loop nil)
    (setq B (+ B (* wid dep))
  )
    )
  )
)
       )
     (setq B (+ A B)
  neck (* (/ A B) main)
  )
     )
    )
  (prompt (strcat "\nThe neck will be " (rtos neck 5 4) "\""))
  (princ)
  )

daron

  • Guest
Swamped again!
« Reply #6 on: March 10, 2004, 07:35:02 AM »
That's great. Glad you figured it out.

Royalchill

  • Guest
Re: Swamped again!
« Reply #7 on: December 13, 2005, 03:33:11 PM »
I don't know about your lisp bro. I been in the sheetmetal trade awhile and i would say if your doing a nested fitting, that fitting should look like this. hope this comes, not sure how to attach a cad dwg