길이(LM) 리습에 "L =" 값 "m" / 면적(AQ) 리습에 "A =" 값 "m2″ 로 값 앞 뒤로 붙이고 싶어요. 도와주세요!
컨텐츠 정보
- 324 조회
- 0 추천
- 0 비추천
- 목록
본문
——————- 길이산출 (LM) 리습이구 L = 99.99 m 로 표기하고 싶어요 —————————
(princ "n Eltity Length Sum")
(setvar "cmdecho" 0)
(setq ss (ssget (list (cons 0 "LINE,CIRCLE,ARC,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE"))))
(if ss
(progn
(setq index 0)
(setq linelist nil)
(setq linenumlist nil)
(repeat (sslength ss)
(setq ent (ssname ss index))
(command-s "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 "L = " (rtos (/ (nth count linelist) 1.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개"))
;;;;(setq txt (strcat "L = " (rtos (/ (nth count linelist) 1.0) 2 2)))
(setq txt (strcat "L = " (rtos (/ (nth count linelist) 1000.0) 2 2) "*" (rtos (nth count linenumlist) 2 0) "개"))
(setq txt (strcat "L = " (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"))
(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)
)
——————- 면적산출 (AQ리습)구, A = 99.99 m2 로 표기하고 싶어요 —————————
(defun c:aq( / doc space ss index obj mi mx minpt maxpt inspt area txtobj )
(setvar "cmdecho" 0)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(cond
((= (vla-get-activespace doc) 1) (setq space (vla-get-modelspace doc)))
((= (vla-get-activespace doc) 0) (setq space (vla-get-paperspace doc)))
)
(if (setq ss (ssget (list (cons 0 "CIRCLE,ARC,*POLYLINE,LINE,ELLIPSE,SPLINE"))))
(if (or (setq ts (getreal (strcat "n텍스트 높이 입력 <" (vl-princ-to-string (getvar "textsize")) ">:"))) (setq ts (getvar "textsize")))
(progn
(setvar "textsize" ts)
(setq index 0)
(repeat (sslength ss)
(setq obj (vlax-ename->vla-object (ssname ss index)))
(vla-getboundingbox obj 'mi 'mx)
(setq minpt (vlax-safearray->list mi) maxpt (vlax-safearray->list mx))
(setq inspt (polar minpt (angle minpt maxpt) (/ (distance minpt maxpt) 2)))
(setq inspt (list (car inspt) (+ (cadr inspt) (* ts 2))))
(setq area (vla-get-area obj)) ;len (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)))
(setq a "" b (rtos (/ area 1000000.) 2 2) )
(setq p (vlax-3d-point inspt))
(setq txtobj (vla-addtext space (strcat a b) p ts))
(vla-put-alignment txtobj 4)
(vla-put-textalignmentpoint txtobj p)
(setq inspt (polar inspt (/ (* 270 pi) 180) (* ts 2)))
(setq index (1+ index))
)
;(command "chprop" (ssget "x" '((0 . "TEXT") (1 . "평*"))) "" "c" "7″ "")
)
)
)
(princ)
)
(vl-load-com)
(prompt "n[ AQ ]") ;;;;