本帖最后由 作者 于 2004-8-7 16:23:01 编辑
- (defun C:tt(/ str1 str2 tmp1 tmp2 area1 area2)
- (setq str1 (cdr (assoc 1 (entget (car (entsel "\n选择第一个text: ")))))
- str2 (cdr (assoc 1 (entget (car (entsel "\n选择第二个text: ")))))
- )
- (setq tmp1 (Parse_It (vl-string-subst "x" "%%131" (last (Parse_It str1 ";"))) "x")
- tmp2 (Parse_It (vl-string-subst "x" "%%131" (last (Parse_It str2 ";"))) "x")
- )
- (setq area1 (* (read (car tmp1)) (CirArea (read (cadr tmp1))))
- area2 (* (read (car tmp2)) (CirArea (read (cadr tmp2))))
- )
- (if (> area2 (/ area1 4))
- (princ "\n腰筋面积>1/4底筋面积.")
- (princ "\n腰筋面积<=1/4底筋面积.")
- )
- (princ)
- )
- ;计算园面积
- (defun CirArea (dia)
- (* pi dia dia 0.25)
- )
- ; 字符串分拆 作者: 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)
- )
- ;
|