안녕하세요.
좌표 리습을 구해서 사용중인데요.
X20.145 이렇게 소수점 아랫자리가 발생하면 ( . )이 당연히 생기지만,
<기존> → <변경>
X10 → X10.
Y250 → Y250.
위의 <기존> 예시와 같이 현재 좌표값을 뽑으면 값이 정수로 떨어질때는 ( . )이 없습니다, <변경> 예시처럼 정수로 치수가 떨어질땐 강제로 ( . )을 추가하고 싶은데 가능할까요?
현재 사용중인 리습 추가합니다.
읽어주셔서 감사합니다.
PS. 현재 사용중인 리습 개발자분께도 깊은 감사를 드립니다.
(defun c:XY( / makeLayer maketextstyle searchmleaderstyle makemleaderstyle oldlayer oldcmleaderstyle pt1 pt2 xcoordinate ycoordinate allcoordinate)
(vl-load-com)
(defun makeLayer (newlayername newlayerColor)
(entmake
(list
(cons 0 “LAYER”)
(cons 100 “AcDbSymbolTableRecord”)
(cons 100 “AcDbLayerTableRecord”)
(cons 2 newlayername);layer name
(cons 70 0)
(cons 62 newlayerColor);layer color
)
)
)
(defun maketextstyle (newstylename)
(entmake
(list
(cons 0 “style”)
(cons 100 “AcDbSymbolTableRecord”)
(cons 100 “AcDbTextStyleTableRecord”)
(cons 2 newstylename);style name
(cons 3 “arial.ttf”);font
;(cons 4 “whgtxt.shx”);bigfont
(cons 70 0)
(cons 40 0);fixed height / 0=non
(cons 41 1);width factor
(cons 50 0);oblique angle
(cons 71 0);2=mirrored in X / 4=mirrored in Y
)
)
)
(defun searchmleaderstyle (mleaderstylename / mleaderstyledict searchresult)
(if
(setq mleaderstyledict (dictsearch (namedobjdict) “acad_mleaderstyle”))
(foreach x mleaderstyledict
(if
(and
(= (car x) 3)
(eq (strcase (cdr x)) (strcase mleaderstylename))
)
(setq searchresult t)
)
)
)
searchresult
)
(defun makemleaderstyle (newmleadername newmleadertextstyle)
(setq mleaderstyles (vla-item (vla-get-Dictionaries (vla-get-ActiveDocument (vlax-get-acad-object))) “ACAD_MLEADERSTYLE”))
(setq newmleaderstyle (vla-AddObject mleaderstyles newmleadername “AcDbMLeaderStyle”))
(vla-put-TextStyle newmleaderstyle newmleadertextstyle)
(vla-put-TextAngleType newmleaderstyle “1”)
(vla-put-ArrowSize newmleaderstyle “100”)
(vla-put-DoglegLength newmleaderstyle “100”)
(vla-put-TextHeight newmleaderstyle “100”)
(vla-put-TextLeftAttachmentType newmleaderstyle “3”)
(vla-put-TextRightAttachmentType newmleaderstyle “3”)
)
(if
(= (tblsearch “style” “xycoordinates”) nil)
(maketextstyle “xycoordinates”)
(princ)
)
(setq oldlayer (getvar “clayer”))
(if
(= (tblsearch “layer” “xycoordinates”) nil)
(progn
(makelayer “xycoordinates” 1)
(setvar “clayer” “xycoordinates”)
)
(setvar “clayer” “xycoordinates”)
)
(setq oldcmleaderstyle (getvar “cmleaderstyle”))
(if
(= (searchmleaderstyle “xycoordinates”) nil)
(progn
(makemleaderstyle “xycoordinates” “xycoordinates”)
(setvar “cmleaderstyle” “xycoordinates”)
)
(setvar “cmleaderstyle” “xycoordinates”)
)
(setq pt1 (getpoint “nClick point to measure”))
(if pt1
(progn
(setq xcoordinate (strcat “Z” (rtos (car pt1) 2 3))) ; X좌표
(setq ycoordinate (strcat “X” (rtos (*(cadr pt1)2) 2 3))) ; Y좌표
(setq allcoordinate (strcat Ycoordinate “n” Xcoordinate))
(command “mleader” pt1 pause allcoordinate)
)
)
(setvar “clayer” oldlayer)
(setvar “cmleaderstyle” oldcmleaderstyle)
(princ)
)
이젠 출처도 없이 떠도네요.
(setq xcoordinate (strcat “Z” (rtos (car pt1) 2 3))) ; X좌표
(setq ycoordinate (strcat “X” (rtos (*(cadr pt1)2) 2 3))) ; Y좌표
이 두 줄을 아래의 내용으로 바꾸세요
(if (not (vl-string-search “.” (rtos (car pt1) 2 3)))
(setq xcoordinate (strcat “Z=” (rtos (car pt1) 2 3) “.”))
(setq xcoordinate (strcat “Z=” (rtos (car pt1) 2 3)))
)
(if (not (vl-string-search “.” (rtos (cadr pt1) 2 3)))
(setq ycoordinate (strcat “X=” (rtos (cadr pt1) 2 3) “.”))
(setq ycoordinate (strcat “X=” (rtos (cadr pt1) 2 3)))
)
감사합니다 덕분에 잘 해결했습니다.
출처를 확인해보니 프로그램 맨 뒤에 적혀있네요,
출처 : https://blog.naver.com/trusted_dwg
제작자분, 도움을 주신분 모두 감사드립니다. 잘 쓰겠습니다^^
수고하셨네요.
(setq xcoordinate (strcat “Z” (rtos (car pt1) 2 3)”.”)) ; X좌표
(setq ycoordinate (strcat “X” (rtos (*(cadr pt1)2) 2 3)”.”)) ; Y좌표
선생님 댓글 감사합니다.
말씀주신것처럼 해보니, 정수로 끝나는 좌표는 문제없이 .이 찍히는데, 문제는 소수점으로 끝나는 좌표(실수)끝에도 .이 찍힙니다.
ex) X23.23. ←이미 정수가 아닌 소수점(실수)이라 마지막에 .이 필요없지만 찍힙니다 ㅠ
※ 정리
정수로 끝나는 좌표만 . 을 추가할 수 없을까요?