|
;;----------------------------------------------------------------------------------
(defun C:ff ( / *error* subTextSort $str->number ss n mutt e entlst entxt txLst thk thk1 sz qt ut wt val nut out utt nwt owt wtt utw density)
(vl-load-com)
(defun *error* (msg)(princ "\nerror:")(princ msg)
(if (/= mutt (getvar 'nomutt))(setvar 'nomutt mutt))
(princ)
)
;;;*************************************************************************************
;;; author : 달수님 http://cafe.daum.net/notcolor & http://cafe.daum.net/archimore
;;; 설 명: 문자를 가로로 정렬 - 문자크기로 유격설정
;;; 매개변수: ss <ename객체>
;;; 사 용 법: (setq ss (ssget '((0 . "text")))) (setq txtLst (subTextSort ss))
;;;*************************************************************************************
(defun subTextSort (ss / sAs sE sI sSo sYS sRan sLs sLf sA tH sL nL tp Y tL L)
(defun sAs (num x)(cdr (assoc num x)))
(defun sE (x) (vl-remove-if 'listp (mapcar 'cadr (ssnamex x))))
(defun sI (x / a72 a73)
(setq a72 (sAs 72 x) a73 (sAs 73 x))
(if (not (and (= a72 0)(= a73 0)))(sAs 11 x)(sAs 10 x))
)
(defun sSo (x)(vl-sort x '(lambda (x1 x2)(< (caar x1) (caar x2)))))
(defun sYS (x)(vl-sort x '(lambda (y1 y2)(> (cadaar y1) (cadaar y2)))))
(defun sRan (x)(if (< (- (cadr x) tH) Y (+ (cadr x) tH)) T nil))
(defun sLs (x)(if (sRan (car x))(setq sL (cons x sL))(setq tp (cons x tp))))
(defun sLf (x)
(setq Y (cadar x))(mapcar 'sLs nL)
(setq sL (sSo sL) tL (cons sL tL) nL tp sL '() tp '())
)
(defun sA (x)(list (cdr (assoc 1 (entget (cadr x))))(cadr x)))
(setq L (mapcar '(lambda (x) (list (sI (entget x)) x))(sE ss)))
(setq L (sSo L) tH (sAs 40 (entget (cadar L))) nL L)
(mapcar '(lambda (x)(if (member x nL)(sLf x))) L)
(mapcar '(lambda (x)(mapcar 'sA x)) (sYS tL))
)
;;----------------------------------------------------------------------------------
;; ($str->number "PL10x50x50") ==> (10.0 50.0 50.0)
;;----------------------------------------------------------------------------------
(defun $str->number ($string / $string $str_len $count $str1 $num_str $num_list)
(setq
$str_len (strlen $string)
$num_str ""
$num_list nil
$count 1
)
(repeat (1+ $str_len)
(setq $str1 (substr $string $count 1))
(if (or (= 46 (ascii $str1)) (<= 48 (ascii $str1) 57))
(setq $num_str (strcat $num_str $str1))
(progn
(if (/= $num_str "")
(setq $num_list (append $num_list (list (atof $num_str))))
)
(setq $num_str "")
)
)
(setq $count (1+ $count))
)
;(print $num_list)
$num_list
)
;;서브함수 추가
;;----------------------------------------------------------------------------------
(defun subShapeSteel_WT ($a $thk1 / $sz $qt $ut $wt $utt $out $nut $utw $val $wtt $owt $nwt)
(setq $sz (atof (car (nth 3 $a))))
(setq $qt (atoi (car (nth 4 $a))))
(if (= (length $a) 8)
(setq $ut (cadr (nth 6 $a)))
(setq $ut nil)
)
(setq $wt (cadr (last $a)))
(if $ut
(progn
(setq $utt (entget $ut))
(setq $out (assoc 1 $utt))
(setq $nut (cons 1 (setq $utw (rtos (* $thk1 (/ $sz 1000)) 2 2))))
(setq $val (* (atof $utw) $qt))
(entmod (subst $nut $out $utt))
)
(setq $val (* $thk1 (/ $sz 1000) $qt))
)
(setq $wtt (entget $wt))
(setq $owt (assoc 1 $wtt))
(setq $nwt (cons 1 (rtos $val 2 2)))
(entmod (subst $nwt $owt $wtt))
)
;;----------------------------------------------------------------------------------
(setq mutt (getvar 'nomutt))
(prompt "\n텍스트 선택:")
(setq mutt(getvar 'nomutt ))
(if (= mutt 0)(setvar 'nomutt 1))
(setq ss (ssget (list (cons 0 "TEXT"))))
(if (/= mutt (getvar 'nomutt))(setvar 'nomutt mutt))
(setq txLst (subTextSort ss))
(if txLst
(foreach a txLst
(setq thk (car (nth 2 a)))
(if (= (substr thk 1 5) "HSA-F")
(progn
(setq thk1
(cond
((= thk "HSA-F M10x98" ) 0.07)
((= thk "HSA-F M12x145") 0.13)
((= thk "HSA-F M16x137") 0.23)
((= thk "HSA-F M16x182") 0.29)
((= thk "HSA-F M20x170") 0.44)
)
)
(setq qt (atoi (car (nth 3 a))))
(if (= (length a) 7)
(setq ut (cadr (nth 5 a)))
(setq ut nil)
)
(setq wt (cadr (last a)))
(if ut
(progn
(setq utt (entget ut))
(setq out (assoc 1 utt))
(setq nut (cons 1 (setq utw (rtos thk1 2 2))))
(setq val (* (atof utw) qt))
(entmod (subst nut out utt))
)
(setq val (* thk1 qt))
)
(setq wtt (entget wt))
(setq owt (assoc 1 wtt))
(setq nwt (cons 1 (rtos val 2 2)))
(entmod (subst nwt owt wtt))
)
(cond
((= (substr thk 1 1) "H" )
(progn
(setq thk1
(cond
((= thk "H100x50x5x7" ) 9.3) ((= thk "H100x100x6x8" ) 17.2) ((= thk "H125x60x6x8" ) 13.2) ((= thk "H125x125x6.5x9") 23.8)
((= thk "H150x75x5x7" ) 14.0) ((= thk "H148x100x6x9" ) 21.1) ((= thk "H150x150x7x10" ) 31.5) ((= thk "H175x90x5x8" ) 18.1)
((= thk "H175x175x7.5x11")40.2) ((= thk "H198x99x4.5x7" ) 18.2) ((= thk "H200x100x5.5x8") 21.3) ((= thk "H194x150x6x9" ) 30.6)
((= thk "H200x200x8x12" ) 49.9) ((= thk "H200x204x12x12") 56.2) ((= thk "H208x202x10x16") 65.7) ((= thk "H248x124x5x8" ) 25.7)
((= thk "H250x125x6x9" ) 29.6) ((= thk "H244x252x11x11") 64.4) ((= thk "H248x249x8x13" ) 66.5) ((= thk "H244x175x7x11" ) 44.1)
((= thk "H250x250x9x14" ) 72.4) ((= thk "H250x255x14x14") 82.2) ((= thk "H298x149x5.5x8") 32.0) ((= thk "H300x150x6.5x9") 36.7)
((= thk "H294x200x8x12" ) 56.8) ((= thk "H298x201x9x14" ) 65.4) ((= thk "H294x302x12x12") 84.5) ((= thk "H298x299x9x14" ) 87.0)
((= thk "H300x300x10x15") 94.0) ((= thk "H300x300x11x12") 82.5) ((= thk "H304x301x11x17") 106) ((= thk "H300x305x15x15") 106)
((= thk "H346x174x6x9" ) 41.4) ((= thk "H350x175x7x11" ) 49.6) ((= thk "H336x249x8x12" ) 69.2) ((= thk "H340x250x9x14" ) 79.7)
((= thk "H338x351x13x13") 106) ((= thk "H344x348x10x16") 115) ((= thk "H344x354x16x16") 131) ((= thk "H350x350x12x19") 137)
((= thk "H350x357x19x19") 156) ((= thk "H356x352x14x22") 159) ((= thk "H396x199x7x11" ) 56.6) ((= thk "H400x200x8x13" ) 66.0)
((= thk "H386x299x9x14" ) 94.3) ((= thk "H390x300x10x16") 107) ((= thk "H388x402x15x15") 140) ((= thk "H394x398x11x18") 147)
((= thk "H394x405x18x18") 168) ((= thk "H400x400x13x21") 172) ((= thk "H400x408x21x21") 197) ((= thk "H406x403x16x24") 200)
((= thk "H414x405x18x28") 232) ((= thk "H428x407x20x35") 283) ((= thk "H458x417x30x50") 415) ((= thk "H498x432x45x70") 605)
((= thk "H446x199x8x12" ) 66.2) ((= thk "H450x200x9x14" ) 76.0) ((= thk "H434x299x10x15") 106) ((= thk "H440x300x11x18") 124)
((= thk "H496x199x9x14" ) 79.5) ((= thk "H500x200x10x16") 89.6) ((= thk "H506x201x11x19") 103) ((= thk "H482x300x11x15") 114)
((= thk "H488x300x11x18") 128) ((= thk "H502x465x15x25") 240) ((= thk "H522x470x20x35") 334) ((= thk "H532x475x25x40") 392)
((= thk "H552x480x30x50") 488) ((= thk "H552x485x35x50") 509) ((= thk "H572x490x40x60") 608) ((= thk "H572x495x45x60") 631)
((= thk "H572x500x50x60") 653) ((= thk "H546x199x9x14" ) 38.6) ((= thk "H550x200x10x16") 94.2) ((= thk "H554x201x11x18") 105)
((= thk "H560x202x12x21") 119) ((= thk "H564x203x13x23") 129) ((= thk "H596x199x10x15") 94.6) ((= thk "H600x200x11x17") 106)
((= thk "H606x201x12x20") 120) ((= thk "H612x202x13x23") 134) ((= thk "H582x300x12x17") 137) ((= thk "H588x300x12x20") 151)
((= thk "H594x302x14x23") 175) ((= thk "H692x300x13x20") 166) ((= thk "H700x300x13x24") 185) ((= thk "H708x302x15x28") 215)
((= thk "H792x300x14x22") 191) ((= thk "H800x300x14x26") 210) ((= thk "H808x302x16x30") 241) ((= thk "H890x299x15x23") 213)
((= thk "H900x300x16x28") 243) ((= thk "H912x302x18x34") 286) ((= thk "H200x100x6x9") 22.7)
)
)
(subShapeSteel_WT a thk1)
)
)
((= (substr thk 1 1) "C")
(progn
(setq thk1
(cond
((= thk "C75x40x5x7" ) 6.92) ((= thk "C100x50x5x7.5" ) 9.36) ((= thk "C125x65x6x8" ) 13.4) ((= thk "C150x70x6x8.5" ) 15.8)
((= thk "C150x75x6.5x10" ) 18.6) ((= thk "C150x75x9x12.5" ) 24.0) ((= thk "C180x75x7x10.5") 21.4) ((= thk "C180x90x7.5x12.5") 27.1)
((= thk "C200x70x7x10" ) 21.1) ((= thk "C200x80x7.5x11" ) 24.6) ((= thk "C200x90x8x13.5") 30.3) ((= thk "C230x80x8x12" ) 28.4)
((= thk "C230x90x8.5x13.5") 33.1) ((= thk "C250x80x8x12.5" ) 30.2) ((= thk "C250x90x9x13" ) 34.6) ((= thk "C250x90x11x14.5" ) 40.2)
((= thk "C280x100x9x13" ) 38.8) ((= thk "C280x100x11.5x16") 48.2) ((= thk "C300x90x9x13" ) 38.1) ((= thk "C300x90x10x15.5" ) 43.8)
((= thk "C300x90x10.5x15.5") 44.8) ((= thk "C300x90x12x16" ) 48.6) ((= thk "C300x100x10x16") 46.8) ((= thk "C300x100x12x18" ) 54.0)
((= thk "C380x100x10.5x16") 54.5) ((= thk "C380x100x13x16.5") 62.0) ((= thk "C380x100x13x20") 67.3)
)
)
(subShapeSteel_WT a thk1)
)
)
((= (substr thk 1 1) "L")
(progn
(setq thk1
(cond
((= thk "L20x20x3" ) 0.885) ((= thk "L25x25x3" ) 1.12) ((= thk "L30x30x3" ) 1.36) ((= thk "L30x30x5" ) 2.16)
((= thk "L35x35x3" ) 1.60) ((= thk "L35x35x5" ) 2.56) ((= thk "L40x40x3" ) 1.83) ((= thk "L40x40x5" ) 2.95)
((= thk "L45x45x3" ) 2.09) ((= thk "L45x45x4" ) 2.74) ((= thk "L45x45x6" ) 3.96) ((= thk "L45x45x8" ) 5.15)
((= thk "L50x50x4" ) 3.06) ((= thk "L50x50x6" ) 4.43) ((= thk "L50x50x8" ) 5.78) ((= thk "L60x60x4" ) 3.68)
((= thk "L60x65x5" ) 4.55) ((= thk "L60x60x6" ) 5.37) ((= thk "L60x60x7" ) 6.21) ((= thk "L60x60x9" ) 7.85)
((= thk "L65x65x5" ) 5.00)
((= thk "L65x65x6" ) 5.91) ((= thk "L65x65x8" ) 7.66) ((= thk "L65x65x10" ) 9.42) ((= thk "L70x70x6" ) 6.38)
((= thk "L75x75x6" ) 6.85) ((= thk "L75x75x9" ) 9.96) ((= thk "L75x75x12" ) 13.0) ((= thk "L80x80x6" ) 7.32)
((= thk "L90x90x6" ) 8.28) ((= thk "L90x90x7" ) 9.59) ((= thk "L90x90x10" ) 13.3) ((= thk "L90x90x13" ) 17.0)
((= thk "L100x100x7" ) 10.7) ((= thk "L100x100x10") 14.9) ((= thk "L100x100x13") 19.1) ((= thk "L120x120x8" ) 14.7)
((= thk "L130x130x9" ) 17.9) ((= thk "L130x130x12") 23.4) ((= thk "L130x130x15") 28.8) ((= thk "L150x150x10") 22.9)
((= thk "L150x150x12") 27.3) ((= thk "L150x150x15") 33.6) ((= thk "L150x150x19") 41.9) ((= thk "L175x175x12") 31.8)
((= thk "L175x175x15") 39.4) ((= thk "L200x200x15") 45.3) ((= thk "L200x200x20") 59.7) ((= thk "L200x200x25") 73.6)
((= thk "L250x250x25") 93.7) ((= thk "L250x250x35") 128 )
((= thk "L65x50x5") 4.36) ((= thk "L65x50x7") 5.94) ((= thk "L65x50x9") 7.49) ((= thk "L75x50x6") 5.67)
((= thk "L75x50x9") 8.20) ((= thk "L75x65x6") 6.38) ((= thk "L75x65x8") 8.29) ((= thk "L75x65x9") 9.26)
((= thk "L75x65x10") 10.2) ((= thk "L90x75x6") 7.56) ((= thk "L90x75x9") 11.0) ((= thk "L90x75x12") 14.4)
((= thk "L100x75x7") 9.32) ((= thk "L100x75x10") 13.0) ((= thk "L100x75x13") 16.5) ((= thk "L100x80x7") 9.59)
((= thk "L100x80x10") 13.3) ((= thk "L100x80x13") 17.0) ((= thk "L125x75x7") 10.7) ((= thk "L125x75x9") 13.5)
((= thk "L125x75x10") 14.9) ((= thk "L125x75x13") 19.1) ((= thk "L125x90x7") 11.5) ((= thk "L125x90x9") 14.6)
((= thk "L125x90x10") 16.1) ((= thk "L125x90x13") 20.6) ((= thk "L150x90x9") 16.4) ((= thk "L150x90x12") 21.5)
((= thk "L150x90x15") 26.5) ((= thk "L150x100x9") 17.1) ((= thk "L150x100x12") 22.4) ((= thk "L150x100x15") 27.7)
)
)
(subShapeSteel_WT a thk1)
)
)
((= (substr thk 1 2) "PL")
(progn
(setq density
(if (= (atoi (car (nth 4 a))) "SS400")
(7.85))
(if (= (atoi (car (nth 4 a))) "A36")
(7.85))
(if (= (atoi (car (nth 4 a))) "SUS309")
(7.88))
(if (= (atoi (car (nth 4 a))) "SUS304")
(7.90))
(if (= (atoi (car (nth 4 a))) "SUS430")
(7.70)))
(setq sz ($str->number (car (nth 2 a))))
(setq qt (atoi (car (nth 3 a))))
(if (= (length a) 7)
(setq ut (cadr (nth 5 a)))
(setq ut nil)
)
(setq wt (cadr (last a)))
(if ut
(progn
(setq utt (entget ut))
(setq out (assoc 1 utt))
(setq nut (cons 1 (setq utw (rtos (* (apply '* (mapcar '(lambda (x) (/ x 1000)) sz)) (* density 1000)) 2 2))))
(setq val (* (atof utw) qt))
(entmod (subst nut out utt))
)
(setq val (* (apply '* (mapcar '(lambda (x) (/ x 1000)) sz)) (* density 1000) qt ))
)
(setq wtt (entget wt))
(setq owt (assoc 1 wtt))
(setq nwt (cons 1 (rtos val 2 2)))
(entmod (subst nwt owt wtt))
)
)
)
)
)
)
(princ)
)
;;;;;;;;;;;
(SETQ density 만약에 리스트 A의 4번째가 재질"SS400"이면 7.85
리스트 A의 4번째가 재질 "SUS309"이면 7.88 등등 이런식으로 넣었는데 문법 에러가 뜹니다.
IF가 계속 중첩이 되는건 아닌가요?
|
첫댓글 if 를 cond 문으로 바꿔서 적용해보세요
그리고 atoi 함수는 문자를 정수로 변환 합니다.
그래서 여기서는 필요없는 함수죠
(setq density
(cond
((= (car (nth 4 a)) "SS400") 7.85)
((= (car (nth 4 a)) "A36") 7.85)
((= (car (nth 4 a)) "SUS309") 7.88)
((= (car (nth 4 a)) "SUS304") 7.90)
((= (car (nth 4 a)) "SUS430") 7.70)
)
)
감사합니다!
atoi가 문자를 정수로! 또 하나 배웠습니다
좋은 하루 보내세요~