获取光标位置
如果获取光标所在的像素点,和左下角、右上角的像素点 <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-pagination: widow-orphan">SCREENSIZE 系統變數(唯讀)<BR>類型:2D 點<BR>不儲存 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-pagination: widow-orphan">儲存目前視埠的尺寸<SPAN lang=EN-US> (X 和 Y),以像素為單位。 <o:p></o:p></SPAN>
<P class=tablebody style="MARGIN: auto 0cm">VIEWCTR系統變數(唯讀)<o:p></o:p>
<P class=tablebody style="MARGIN: auto 0cm">類型:<SPAN lang=EN-US>3D 點<BR>儲存於:圖面 <o:p></o:p></SPAN>
<P class=tablebody style="MARGIN: auto 0cm">儲存目前視埠內的視景中心點。以<SPAN lang=EN-US> UCS 座標表示。 <o:p></o:p></SPAN>
<P class=tablebody style="MARGIN: auto 0cm">再比較<SPAN style="COLOR: black; mso-bidi-font-weight: bold">光标位置<SPAN lang=EN-US>,再計算</SPAN><o:p></o:p></SPAN> 中心点的UCS能获取,却又不知像素点的坐标啊,
它们的单位不一样,怎么比较? <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3>看看这个例子</FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman">http://bbs.mjtd.com/forum.php?mod=viewthread&tid=7081&replyID=26614<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT> 这样也不行啊,返回的都只是UCS坐标,如果能知道一点的UCS坐标和像素点坐标就行了,不知能否调用API函数GetCursorPos来返回该像素点坐标? 像素点坐标的真正意义是甚么?
自己算一下即可!
(defun C:TT (/ PT1)<BR> (command "_.UCS" "V")<BR> (while (/= 3 (car (setq PT1 (grread 5 1))))<BR> (print (GETCURSORPOS (cadr PT1)))<BR> )<BR> (command "_.UCS" "p")<BR>)
(defun GETCURSORPOS (PT1 / CTR YSIZE SCREEN SCALE XSIZE LB XX YY)<BR> (setq CTR (getvar "VIEWCTR"))<BR> (setq YSIZE (getvar "VIEWSIZE"))<BR> (setq SCREEN (getvar "SCREENSIZE"))<BR> (setq SCALE (/ (car SCREEN) (cadr SCREEN)))<BR> (setq XSIZE (* SCALE YSIZE))<BR> (setq LB (list (- (car CTR) (/ XSIZE 2)) (- (cadr CTR) (/ YSIZE 2))))<BR> (setq XX (- (car PT1) (car LB)))<BR> (setq YY (- (cadr PT1) (cadr LB)))<BR> (list (* (/ XX XSIZE) (car SCREEN))<BR> (* (/ YY YSIZE) (cadr SCREEN))<BR> )<BR>) 感谢
页:
[1]