면접 합계를 계산식으로 표기
컨텐츠 정보
- 350 조회
- 10 댓글
- 0 추천
- 0 비추천
- 목록
본문
아래 리습은 길이 합계를 계산식으로 표기될수 있게해주는 리습입니다만
면적 합계를 계산식으로 표기하고 싶습니다 ㅠ 도움 부탁드립니다.
(defun c:MM (/ ss sslist i index linelist linenumlist ent old10 old11 dist lnum count temp total total1 subtotal txt pt)
(vl-load-com) ;—->total1 추가함
(princ "n Eltity Length Sum")
(setvar "cmdecho" 0)
(setq ss (ssget (list (cons 0 "LINE,CIRCLE,ARC,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE"))))
(setq zzz (sslength ss))
(if ss
(progn
(setq index 0)
(setq linelist nil)
(setq linenumlist nil)
(repeat (sslength ss)
(setq ent (ssname ss index))
(command "lengthen" ent "")
(setq dist (GETVAR "PERIMETER"))
(if (apply 'or (mapcar '(lambda (x) (equal dist x 1)) linelist))
(progn
(setq temp 0)
(setq lnum nil)
(foreach x linelist
(if (equal dist x 1)
(setq lnum temp)
)
(setq temp (1+ temp))
)
(setq count 0)
(setq temp nil)
(foreach x linenumlist
(if (= count lnum)
(setq temp (append temp (list (+ x 1))))
(setq temp (append temp (list x)))
)
(setq count (1+ count))
)
(setq linenumlist temp)
)
(progn
(setq linelist (append linelist (list dist)))
(setq linenumlist (append linenumlist (list 1)))
)
)
(setq index (1+ index))
)
(setq txt "")
(setq count 0)
(setq total 0)
(setq subtotal 0)
(repeat (length linelist)
(if (= count 0)
(if (> (nth count linenumlist) 1)
;;;;(setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개"))
;;;;(setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1.0) 2 2)))
(setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1000.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개"))
(setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1000.0) 2 2)))
)
(if (> (nth count linenumlist) 1)
;;;;(setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개"))
;;;;(setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1.0) 2 2)))
(setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1000.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개"))
(setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1000.0) 2 2)))
)
)
(setq subtotal (* (/ (nth count linelist) 1) (nth count linenumlist)))
(setq total (+ subtotal total))
(setq total1 (/ total 1000));————->추가함
(setq count (1+ count))
)
;;;;(setq txt (strcat txt " = " (rtos total 2 2) "m"))
(setq txt (strcat txt " = " (rtos total1 2 2) "m"));——->total에서 total1 변경함
(setq txt (strcat txt " : 객체수 " (rtos zzz 2 0) " 개"))
(princ txt)
(if (not (setq tth (getreal (strcat "n현재 TextSize : <" (rtos(getvar "textsize") 2 1) "> 입니다. 원하는 Text 크기를 입력하세요 : "))))
(setq tth (getvar "textsize"))
(setvar "textsize" tth)
)
(setq pt (getpoint "n 텍스트 삽입점 : "))
(if pt (command "text" pt "" "" txt))
)
)
(princ)
)
관련자료
상큼메론90님의 댓글
이 질문은 며칠전에 올라온것 같은데?????
수정했어요~~~ 테스트는 못해 봅니다.
잘 되는지 확인해 보세요
;;;;;;; (defun c:MM (/ ss sslist i index linelist linenumlist ent old10 old11 dist lnum count temp total total1 subtotal txt pt) (vl-load-com) ;—->total1 추가함 (princ "n Eltity Length Sum") (setvar "cmdecho" 0)
(setq ss (ssget (list (cons 0 "LINE,CIRCLE,ARC,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE")))) (setq zzz (sslength ss)) (if ss (progn (setq index 0) (setq linelist nil) (setq linenumlist nil) (repeat (sslength ss) (setq ent (ssname ss index)) (command "area" "e" ent) (setq distt (/ (getvar "area") 1.0e+06)) (setq dist (* distt 0.3025)) ; (if (apply 'or (mapcar '(lambda (x) (equal dist x 1)) linelist)) (progn (setq temp 0) (setq lnum nil) (foreach x linelist (if (equal dist x 1) (setq lnum temp) ) (setq temp (1+ temp)) ) (setq count 0) (setq temp nil) (foreach x linenumlist (if (= count lnum) (setq temp (append temp (list (+ x 1)))) (setq temp (append temp (list x))) ) (setq count (1+ count)) ) (setq linenumlist temp) ) (progn (setq linelist (append linelist (list dist))) (setq linenumlist (append linenumlist (list 1))) ) ) (setq index (1+ index)) ) (setq txt "") (setq count 0) (setq total 0) (setq subtotal 0) (repeat (length linelist) (if (= count 0) (if (> (nth count linenumlist) 1)
;;;;(setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개")) ;;;;(setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1.0) 2 2)))
(setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개")) (setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1.0) 2 2))) ) (if (> (nth count linenumlist) 1)
;;;;(setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개")) ;;;;(setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1.0) 2 2)))
(setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개")) (setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1.0) 2 2))) ) ) (setq subtotal (* (/ (nth count linelist) 1) (nth count linenumlist))) (setq total (+ subtotal total)) (setq total1 (/ total 1000));————->추가함 (setq count (1+ count)) ) ;;;;(setq txt (strcat txt " = " (rtos total 2 2) "m")) (setq txt (strcat txt " = " (rtos total1 2 2) "평"));——->total에서 total1 변경함 (setq txt (strcat txt " : 객체수 " (rtos zzz 2 0) " 개")) (princ txt) (if (not (setq tth (getreal (strcat "n현재 TextSize : <" (rtos(getvar "textsize") 2 1) "> 입니다. 원하는 Text 크기를 입력하세요 : ")))) (setq tth (getvar "textsize")) (setvar "textsize" tth) ) (setq pt (getpoint "n 텍스트 삽입점 : "))
(if pt (command "text" pt "" "" txt)) ) ) (princ) )
;;;;;
상큼메론90님의 댓글
면적이 큰것은 제대로 나오는데 적은것은 그냥 묶어서 나와버리네요~~~
한번더 테스트 해 주세요~~~
(defun c:MM (/ ss sslist i index linelist linenumlist ent old10 old11 dist lnum count temp total total1 subtotal txt pt) (vl-load-com) ;—->total1 추가함 (princ "n Eltity Length Sum") (setvar "cmdecho" 0)
(setq ss (ssget (list (cons 0 "LINE,CIRCLE,ARC,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE")))) (setq zzz (sslength ss)) (if ss (progn (setq index 0) (setq linelist nil) (setq linenumlist nil) (repeat (sslength ss) (setq ent (ssname ss index))
(command "area" "e" ent) (setq distt (/ (getvar "area") 1.0e+06)) (setq dist (* distt 0.3025)) ;평으로 환산 M²* 0.3025
(if (apply 'or (mapcar '(lambda (x) (equal dist x 0)) linelist)) (progn (setq temp 0) (setq lnum nil) (foreach x linelist (if (equal dist x 0) (setq lnum temp) ) (setq temp (1+ temp)) ) (setq count 0) (setq temp nil) (foreach x linenumlist (if (= count lnum) (setq temp (append temp (list (+ x 1)))) (setq temp (append temp (list x))) ) (setq count (1+ count)) ) (setq linenumlist temp) ) (progn (setq linelist (append linelist (list dist))) (setq linenumlist (append linenumlist (list 1))) ) ) (setq index (1+ index)) ) (setq txt "") (setq count 0) (setq total 0) (setq subtotal 0) (repeat (length linelist) (if (= count 0) (if (> (nth count linenumlist) 1)
;;;;(setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개")) ;;;;(setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1.0) 2 2)))
(setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개")) (setq txt (strcat "nL = " (rtos (/ (nth count linelist) 1.0) 2 2))) ) (if (> (nth count linenumlist) 1)
;;;;(setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개")) ;;;;(setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1.0) 2 2)))
(setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개")) (setq txt (strcat txt " + " (rtos (/ (nth count linelist) 1.0) 2 2))) ) ) (setq subtotal (* (/ (nth count linelist) 1) (nth count linenumlist))) (setq total (+ subtotal total)) (setq total1 (/ total 1.0));————->추가함 (setq count (1+ count)) ) ;;;;(setq txt (strcat txt " = " (rtos total 2 2) "m")) (setq txt (strcat txt " = " (rtos total1 2 2) "평"));——->total에서 total1 변경함 (setq txt (strcat txt " : 객체수 " (rtos zzz 2 0) " 개")) (princ txt) (if (not (setq tth (getreal (strcat "n현재 TextSize : <" (rtos(getvar "textsize") 2 1) "> 입니다. 원하는 Text 크기를 입력하세요 : ")))) (setq tth (getvar "textsize")) (setvar "textsize" tth) ) (setq pt (getpoint "n 텍스트 삽입점 : "))
(if pt (command "text" pt "" "" txt)) ) ) (princ) )
;;;
스마트노가다님의 댓글
(setq distt (/ (getvar "area") 1.0e+06)) (setq dist (* distt 0.3025)) ;평으로 환산 M²* 0.3025 <——–이부분 1로 바꾸로 (setq txt (strcat txt " = " (rtos total1 2 2) "평"));——->total에서 total1 변경함 <—이부분 m2으로 출력하게수정했는데여 되긴되는데 이렇게하는거 맞나요??컴퓨터언어는 문외한이라…혼자 1시간 넘게 소스만 보구했는데….각 객체에 대한 면적 " + " 이거 사이에 m2 도 프린트 하고싶은데 그건 어캐하는건가요?