本帖最后由 cabinsummer 于 2016-12-24 15:16 编辑
在作图过程中,有时需看一下图纸当前状态的打印效果是否能看清细小之处,此程序就可实现这个功能。提取变量Dimscale是为了让图纸真实再现打印效果,比如用1:2比例尺,一般图形都按1:1画,缩小一倍打印。desktop和laptop是显示器的点距参数表,一般的民用显示器点距参数都是一定的。desktop为台式机,laptop为笔记本。表由很多字符串构成,每个字符串代表一种显示器参数。字符"\t"左边为显示器大小,"\t"和"\td"之间为标准显示分辨率,"\td"右边是点距。由于采用了硬件的参数,所以显示比较真实。以前见过一些实现类似功能的程序,但都不精确,在窗口大小不同的情况下运行结果会变化(相对于打印效果),本程序则没有这个问题。
;;;Z11.LSP程序
 - (defun c:z11(/ ctr)
- (setq ctr (getpoint "<Select central point>\n"))
- (z11 ctr)
- )
- (defun z11(ctr / desktop laptop DLG_ID llist result pixelpitch zx make_list do_pixelpitch)
- (setvar "cmdecho" 0)
- (defun make_list()
- (start_list "item" 3)
- (mapcar 'add_list llist)
- (end_list)
- )
- (defun do_pixelpitch()
- (setq pixelpitch (nth (atoi $value) llist))
- )
- (if (not (vl-registry-read "HKEY_CURRENT_USER\\Software\\Freebird" "pixelpitch"))
- (progn
- (setq desktop '(
- "12.1\t800*600\td0.308" "12.1\t1024*768\td0.240" "12.1\t1280*800\td0.204"
- "13.3\t1024*768\td0.264" "13.3\t1280*800\td0.224" "14.1\t1024*768\td0.279"
- "14.1\t1280*800\td0.237" "14.1\t1400*1050\td0.204" "14.1\t1440*900\td0.211"
- "15\t1024*768\td0.297" "15\t1400*1050\td0.218" "15\t1600*1200\td0.190"
- "16\t1280*1024\td0.248" "17\t1280*1024\td0.264" "17W\t1280*768\td0.2895"
- "17.4\t1280*1024\td0.270" "18\t1280*1024\td0.281" "19\t1280*1024\td0.294"
- "19\t1600*1200\td0.242" "19W\t1440*900\td0.285" "19W\t1680*1050\td0.243"
- "20.1\t1200*1024\td0.312" "20.1\t1600*1200\td0.255" "20.1W\t1680*1050\td0.258"
- "20.1\t2560*2048\td0.156" "20.8\t2048*1536\td0.207" "21.3\t1600*1200\td0.270"
- "21.3\t2048*1536\td0.210" "21.6W\t1680*1050\td0.276" "22W\t1600*1024\td0.294"
- "22W\t1680*1050\td0.282" "22.2\t3840*2400\td0.1245" "23W\t1920*1200\td0.258"
- "23.1\t1600*1200\td0.294" "24W\t1920*1200\td0.270" "27W\t1920*1200\td0.303"
- "30W\t2560*1600\td0.250"
- )
- laptop '(
- "12.1\t1024*768\td0.240" "13.3\t1024*768\td0.264" "14.1\t1024*768\td0.280"
- "15.1\t1024*768\td0.300" "14.1\t1400*1050\td0.205" "15.1\t1400*1050\td0.219"
- "15.1\t1600*1200\td0.1918" "12.1W\t1280*800\td0.204" "13.3W\t1280*800\td0.224"
- "14.1W\t1280*800\td0.237" "15.4W\t1280*800\td0.259" "17W\t1280*800\td0.286"
- "14.1W\t1440*900\td0.211" "15.4W\t1440*900\td0.230" "17W\t1440*900\td0.254"
- "17W\t1920*1200\td0.191" "19W\t1920*1200\td0.213" "20W\t1920*1200\td0.224"
- )
- )
- (setq DLG_ID (load_dialog "screen.dcl"))
- (new_dialog "screen" DLG_ID)
- (setq llist laptop)
- (make_list)
- (action_tile "LAP" "(setq llist laptop)(make_list)")
- (action_tile "DESK" "(setq llist desktop)(make_list)")
- (action_tile "item" "(do_pixelpitch)")
- (action_tile "accept" "(done_dialog 1)(setq result T)")
- (action_tile "cancel" "(done_dialog 0)")
- (start_dialog)
- (unload_dialog DLG_ID)
- (if result
- (progn
- (setq pixelpitch (substr pixelpitch (+ (vl-string-position 100 pixelpitch) 2)))
- (vl-registry-write "HKEY_CURRENT_USER\\Software\\Freebird" "pixelpitch" pixelpitch)
- )
- )
- )
- )
- (setq pixelpitch (distof (vl-registry-read "HKEY_CURRENT_USER\\Software\\Freebird" "pixelpitch") 2))
- (setq zx (strcat (rtos (/ (getvar "viewsize") (getvar "dimscale") (nth 1 (getvar "screensize")) pixelpitch) 2 4) "X"))
- (command "zoom" "c" ctr "")
- (command "zoom" "s" (eval zx))
- (princ)
- )
;;;SCREEN.DCL文件
 - screen : dialog
- {
- label = "Developed by Freebird";
- :row
- {
- :radio_button
- {
- label="LAPTOP";
- key="LAP";
- value=1;
- width=1;
- }
- :radio_button
- {
- label="DESKTOP";
- key="DESK";
- value=0;
- width=1;
- }
- }
- :list_box
- {
- key="item";
- value=0;
- width=20;
- height=20;
- allow_accept=true;
- tabs = "16 40";
- }
- ok_cancel;
- }
|