기존 텍스트에 특정 텍스를 기입하는 리습니다.
현제는 단일 선택으로 하나씩 눌려 변경하여야 하는데
여러개 객체를 한번에 선택 할수 있는 코드를 어디에서 바꿔야 할까요?
(defun C:PHT ( / 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 "'++") (= Chk_TXT "'++"))
(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 "'++"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 "{'++")
(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 "{'++"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 "{'++")
(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 "{'++"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 "'++") (= Chk_TXT "'++"))
(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 "'++"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
코드를 올리실 경우 공지 사항 한번 읽어 보시고 올리세요
이 리습은 전체를 새로운 구문으로 둘러야 합니다 그런데 이런식으로 코드를 게시하면 수정 하시는 분이 이거 드래그 해서 노가다 해야 합니다.
잘못된 양식의 글을 올려 죄송합니다
사이트 오른쪽에 보이는 공지사항에는 코드 관련 공지가 안 보이는데
어디서 볼 수 있는지 알 수 있을까요?
단순 변경 일줄 알았는데 그렇지 않은가 보네요
ㅎㅎ;; 지금 드래그 해서 살펴보니
리습에 블럭에관한 구문이 있는데 어떻게 처리 해야 하나요 ??
블럭에 문자 하나만 있는 경우와 여러개 있는경우 문자가 단일문자인지 다중문자인지 속성문자인지 블럭에 치수가 포함될수도 있고 블럭때문에 단일 선택으로 사용 하는게 합리적인 리습같습니다 블럭을 빼고 다중 선택으로 해드릴까요?