IT Knowledge Base

~ Without sacrifice, there can be no victory ~

發佈日期:

如何在AutoCAD R15至R17版本中‧使用AutoLISP作快速列印

很多時,列印也是一項麻煩的工作,特別是幾十張的圖紙,明明就是相同的尺寸、邊界、畫筆的顏色,在AutoCAD內也要打開列印版面設置一輪,才可開始列印。

今次設計目的,只需使用者選擇印表機及輸入圖紙的對角位置,其他的全部使用預設設定。

;Sub-program of C:P15.
(DEFUN PS15(T1 T2 / A B A1 A2 B1 B2 A3 A4 B3 B4 MARGIN)
(GRAPHSCR)
(SETVAR "CMDECHO" 0)
(SETVAR "OSMODE" 59)
;Set drawing margin is 5mm.
(SETQ MARGIN 5)
(SETQ A (GETPOINT "\\nEnter upper leftmost point: "))
(SETQ B (GETCORNER A "\\nEnter lower rightmost point: "))
(SETQ A1 (CAR A))
(SETQ A2 (CADR A))
(SETQ B1 (CAR B))
(SETQ B2 (CADR B))
(SETQ A3 (- A1 MARGIN))
(SETQ A4 (+ A2 MARGIN))
(SETQ B3 (+ B1 MARGIN))
(SETQ B4 (- B2 MARGIN))
(SETQ X (LIST A3 A4))
(SETQ Y (LIST B3 B4))
(SETVAR "CMDDIA" 0)
(SETVAR "OSMODE" 0)
(SETQ C (ATOF (GETVAR "ACADVER")))
(IF (AND (>= C 15) (< C 16))
(COMMAND "-PLOT" "Y" "" T1 "A4" "M" T2 "N" "W" A B "F" "0,0" "N" "monochrome.ctb" "Y" "N" "N" "Y" "Y")
)
(IF (AND (>= C 16) (<= C 17))
(COMMAND "-PLOT" "Y" "" T1 "A4" "M" T2 "N" "W" A B "F" "0,0" "N" "monochrome.ctb" "Y" "A" "N" "Y" "Y")
)
(SETVAR "CMDDIA" 1)
(SETVAR "CMDECHO" 1)
(SETVAR "OSMODE" 59)
(GRAPHSCR)
)

;Main program.
(DEFUN C:P15(/ A T1 T2)
(PROMPT "\\nPrint drawing for AutoCAD R15 to R17.")
(SETQ A (ATOF (GETVAR "ACADVER")))
(IF (AND (>= A 15) (<= A 17))
(PROGN
(SETQ B (GETSTRING "\\nAcrobat Distiller Portscape(1)/Landscape(2)/HP LaserJet P3005 PCL 6-p3 Portscape(3)/Landscape(4): "))
(IF (> (ATOI B) 4)
(PROGN
(PROMPT "\\nNot a correct choice.  Program halt.\\n");
(EXIT)
)
)
(IF (OR (= B "1") (= B "2"))
(PROGN
;Printer name should modify to your user's need.
(SETQ T1 "Acrobat Distiller")
)
)
(IF (OR (= B "3") (= B "4"))
(PROGN
;Printer name should modify to your user's need.
(SETQ T1 "HP LaserJet P3005 PCL 6-p3") 
)
)
(IF (OR (= B "1") (= B "3"))
(PROGN
(SETQ T2 "P")
)
)
(IF (OR (= B "2") (= B "4"))
(PROGN
(SETQ T2 "L")
)
)
(PS15 T1 T2)
)
(PROGN
(ALERT "AutoCAD version is not R15, R16 or R17.")
)
)
)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *