
- [FONT=courier new]
- ;;计算钢筋面积
- (defun BarArea (str / e)
- (apply
- '+
- (mapcar '(lambda (x)
- (setq e (Parse_It (vl-string-subst "x" "%%131" x) "x"))
- (* (read (car e)) (CirArea (read (cadr e)))))
- (Parse_It (car (Parse_It str " ")) "+")))
- )
- ;计算园面积
- (defun CirArea (dia)
- (* pi dia dia 0.25)
- )
- ;选筋(对称)
- (defun PickBars (a n / barlst dia1 pos )
- (setq barlst '(12 14 16 18 20 22 25 28 30 32))
- (setq dia1 (1+ (fix (sqrt (/ (* 4 (/ a n)) pi)))))
- (if (not (member dia1 barlst))
- (setq dia1 (nth (setq pos (vl-position
- dia1
- (vl-sort (cons dia1 barlst) '<)))
- barlst))
- (setq pos (vl-position dia1 barlst))
- )
- (if dia1
- (cond
- ((<= n 2)
- (strcat "2%%131" (itoa dia1)))
- ((> n 2)
- (if (> pos 0)
- (if (> (+ (* (- n 2) (CirArea (nth (1- pos) barlst))) (* 2 (CirArea dia1))) a)
- (strcat "2%%131"
- (itoa dia1)
- "+"
- (itoa (- n 2))
- "%%131"
- (itoa (nth (1- pos) barlst)))
- (strcat (itoa n) "%%131" (itoa dia1))
- )
- (strcat (itoa n) "%%131" (itoa dia1))
- );if
- )
- );cond
- ) ;if
- )
- ; 作者: Bill Kramer
- ;
- (defun Parse_It (inStr ;Input string to parse
- Delim ;Delimeter character (or ascii code)
- / Res ;Result list buffer
- Inx ;Character location of delim in string
- InxP ;Previous character location
- )
- ;
- ; Verify DELIM is of the proper type
- ;
- (setq Delim (if (= (type Delim) 'STR)
- (ASCII Delim) ;Convert character to integer
- (if (/= (type Delim) 'INT) ;is it integer?
- 32 ;then use space
- (if (> 0 Delim 256)
- Delim
- 32)))
- ;
- ; Set up parameters for string search loop
- ;
- Inx (VL-String-Position Delim inStr 0)
- InxP -1
- )
- ;
- (while (and Inx (< Inx (strlen inStr)))
- (setq Res
- (cons (substr inStr (+ 2 InxP) (- Inx InxP 1))
- Res)
- InxP Inx
- Inx (VL-String-Position Delim inStr (1+ InxP))
- )
- )
- (setq Res (cons (substr inStr (+ 2 InxP)) Res))
- (reverse Res)
- )
- ;
- [/FONT]
|