숫자 앞에 %%c를 넣어 주는 리습인데 숫자 뒤에 %%d를 넣고 싶어요
수정 할 수 있게 도와주세요!
ex) 300-> %%c300 을 300%%d로 나타내고 싶어요
(defun C:ZC ( / TXT_String LOC ELIST EntType Old_TXT Chk_TXT EntType SUB Sub_Ent)
(while (= TXT_String nil); checks to make sure something was selected
(setq TXT_String (entsel “nPick the text to add Phi symbol :”); if nothing was selected try again
Loc (cadr TXT_String); stores the point picked
TXT_String (car TXT_String)); stores the entity name
(if(= TXT_String nil)
(princ “Nothing Picked”); tell user nothing has been selected
); end if
); end while
(setq ELIST (entget TXT_String))
(setq EntType (cdr (assoc 0 elist))); stores the entity type
(cond
((= EntType “TEXT”)
(setq Old_TXT (cdr (assoc 1 elist)); gets the text from the string
Chk_TXT (substr Old_TXT 1 3); gets the 1st 3 characters of the string for testing
); end setq
(if
(or (= Chk_TXT “%%c”) (= Chk_TXT “%%c”))
(progn
(setq New_Txt (substr Old_TXT 4); removes the Phi if it exists
ELIST (subst (cons 1 New_TXT) (assoc 1 ELIST) ELIST); replaces the existing string
); end setq
); end progn
(progn
(setq New_TXT (strcat “%%c”Old_TXT); adds the Phi
ELIST (subst (cons 1 New_TXT) (assoc 1 ELIST) ELIST);replaces the existing string
); end setq
); end Progn
); end if
)
((= EntType “MTEXT”)
(setq Old_TXT (cdr (assoc 1 elist))
Chk_TXT (substr Old_TXT 1 3); gets the 1st 3 characters of the string for testing
); end setq
(if
(= Chk_TXT “{%%c”)
(progn
(setq Strg_Lngh (- (strlen Old_TXT) 4); checks the string length – the Phi
New_TXT (substr Old_TXT 4 Strg_Lngh); removes the Phi if it exists
ELIST (subst (cons 1 New_TXT) (assoc 1 ELIST) ELIST); replaces the existing string
); end setq
); end progn
(progn
(setq New_TXT (strcat “{%%c”Old_TXT”}”);adds the Phi
ELIST (subst (cons 1 New_TXT) (assoc 1 ELIST) ELIST);replaces the existing string
); end setq
); end Progn
); end if
)
((= EntType “DIMENSION”)
(setq Old_TXT (cdr (assoc 1 elist)); gets the text from the string
Chk_TXT (substr Old_TXT 1 3); gets the 1st 3 characters of the string for testing
);end setq
(if
(= Old_TXT “”)
(setq Old_TXT “<>”)
); end if
(if
(= Chk_TXT “{%%c”)
(progn
(setq Lngh (strlen old_txt)
New_Lngh (- Lngh 4)
New_TXT (substr Old_TXT 4 New_Lngh); removes the Phi if it exists
ELIST (subst (cons 1 New_TXT) (assoc 1 ELIST) ELIST); replaces the existing string
); end setq
); end progn
(progn
(setq New_TXT (strcat “{%%c”Old_TXT”}”) ; adds the Phi
ELIST (subst (cons 1 New_TXT) (assoc 1 ELIST) ELIST); replaces the existing string
); end setq
); end Progn
); end if
)
((= EntType “INSERT”)
(setq SUB (nentselp LOC); Use pick point to select subentity
Sub_Ent (car SUB); Store entity name
Old_TXT (cdr (assoc 1 (entget Sub_Ent))); Retrieve value
Chk_TXT (substr Old_TXT 1 3); gets the 1st 3 characters of the string for testing
); end setq
(if
(or (= Chk_TXT “%%c”) (= Chk_TXT “%%c”))
(progn
(setq ELIST (entget Sub_Ent)
New_Txt (substr Old_TXT 4)
ELIST (subst (cons 1 New_TXT) (assoc 1 ELIST) ELIST)
); end setq
); end progn
(progn
(setq ELIST (entget Sub_Ent)
New_TXT (strcat “%%c”Old_TXT)
ELIST (subst (cons 1 New_TXT) (assoc 1 ELIST) ELIST)
); end setq
); end Progn
); end if
)
((princ “nSelected object is not text”))
); end COND
(entmod ELIST)
(entupd TXT_String)
(princ)
);end defun
감사합니다 !! 즐거운 하루 되세요~