프로그램
캐드 분류

소수점 2째자리까지 안나와요 고수님들 도와주세요 부탁드려요.

컨텐츠 정보

  • 124 조회
  • 1 댓글
  • 0 추천
  • 0 비추천
  • 목록

본문

CAD를 공부하는 학생입니다.
아래 내용중 소수점 2번째까지 나오게 하려면 어떡게 해야하나요.
(defun c:NA(/ tot ind en1 cot tx1 tx2 tx3)
  (princ "n  A + B + …. + C = TOTAL")
  (setq tot (ssget)  ind 0  v1 0)
  (repeat (sslength tot)
    (setq en1 (entget (ssname tot ind)))
    (if (= "TEXT" (cdr (assoc 0 en1)))
      (progn
        (setq tx1 (cdr (assoc 1 en1))  cot 1  tx3 "")
        (repeat (strlen tx1)
          (setq tx2 (substr tx1 cot 1))
          (if (or (and (>= (ascii tx2) 48) (<= (ascii tx2) 57)) (= (ascii tx2) 46))
              (setq tx3 (strcat tx3 tx2))
          )
          (setq cot (1+ cot))
        )
        (setq v1 (+ v1 (atof tx3)))
      )
    )
    (setq ind (1+ ind))
  )
  (princ "nCalculation value : ") (princ v1)
  (princ "nVariable name     : v1″)
  (setq ind 0)
  (if (= d-f_ nil) (setq d-f_ 0))
  (princ "n** A decimal fraction : ") (princ d-f_) (princ " **")
  (while (= nil (setq sel (ssget)))
    (princ "nNumber of fractional places [0 to 8] <") (princ d-f_)
    (setq d-fn (getint ">: "))
    (if (/= d-fn nil) (setq d-f_ d-fn))
  )
  (if (= nil sel) (setq sel (ssget)))
  (repeat (sslength sel)
    (setq ent (entget (ssname sel ind))  ind (1+ ind))
    (if (= (cdr (assoc 0 ent)) "TEXT")
        (entmod (subst (cons 1 (rtos v1 2 d-f_)) (assoc 1 ent) ent))
    )
  )
  (princ)
)
)

관련자료

댓글 1 / 1 페이지

조용!!님의 댓글

d-f_  이놈이 자릿수 변수 입니다… 조정하시면 됩니다.. (rtos   이 함수가.. 실수를 스트링으로 바꾸는거죠..

전체 7,152 / 1 페이지
번호
제목
이름
알림 0