치수를 찍어서 소재 규격을 나타내는 리습을 받아서 사용해 볼려는데..
소수점이 2자리 까지 자동으루 읽어서 나타내내요..
소수점이 없이 나타내려면 어딜 수정 해야 되나요??
고수님들 조언 부탁 합니다~~
(defun c:ss(/ stext ss k ent1 en ed ename tex tex1 tex2 tex3 len str n str1 @1 z ed1)
(prompt “n수식표기하기>> dimension,text,mtext click:”)
(setq stext “” ss nil k 0 ent1 nil)
(while (= nil ss) (setq ss (ssget (list (cons 0 “dimension,text,mtext”))))
(if (= nil ss) (prompt “n>>객체를 다시 선택해주세염”)))
(repeat (sslength ss)
(setq en (ssname ss k)
ed (entget en) n1 z1 @1 nil
ename (cdr (assoc 0 ed))
tex3 (cdr (last (vl-remove-if-not ‘(lambda (x) (= (car x) 100)) ed))))
(cond ((= ename “DIMENSION”)
(setq tex (rtos (cdr (assoc 42 ed)) 2 2)
tex1 (cdr (assoc 1 ed))
tex2 (substr tex1 1 3))
(if (or (= tex1 “%%c”) (= tex2 “%%C”) (= tex3 “AcDbDiametricDimension”)) (setq tex (strcat “%%c” tex)))
)
((= ename “TEXT”)
(setq tex (cdr (assoc 1 ed))))
;—————————————————————
((= ename “MTEXT”)
(setq tex (cdr (assoc 1 ed)))
(setq len (strlen tex))
(if (> len 4)
(progn (setq str (substr tex 1 4))
(if (or (= str “\A0;”) (= str “\A1;”) (= str “\A2;”))
(setq tex (substr tex 5 (- len 4)))
);if
);progn
);if mtext 정렬문자가 있을시 삭제
(repeat (strlen tex)
(setq str (substr tex n 1))
(if (= str “{“) (progn
(cond ((= n 1)
(while (= @1 nil)
(setq str1 (substr tex z 1))
(if (= str1 “\”) (progn
(setq tex (substr tex 2 (- z 1)))
(setq @1 1)
)) ;if progn
(setq z (1+ z)))
)
(t (setq tex (substr tex 1 (- n 1))))
);cond
));if progn
(setq n (1+ n))
);repeat
)
;—————————————————————
);cond
(if (= stext “”) (setq stext tex)
(setq stext (strcat stext “x” tex))
);if
(setq k (1+ k))
);repeat
(prompt “n수식표기문자 선택:”)
(while (= ent1 nil) (setq ent1 (ssget (list (cons 0 “TEXT,MTEXT”))))
(if (= ent1 nil) (prompt “n>>수식표기문자를 다시선택>>:”))
);while
(setq ed1 (entget (ssname ent1 0)))
(entmod (subst (cons 1 stext) (assoc 1 ed1) ed1))
(princ)
);defun
공유