有大佬能改下这个打印代码吗?
命令Y1=根据代码中默认的打印机和打印样式打印,但是这个貌似无法获取图框的范围。
命令Y3=根据图纸中默认打印布局打印文件。不用更改。
需要更改命令Y1中的代码,无法获取图框的范围。
 - (vl-load-com)(setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
- (setvar "cmdecho" 0)
- (defun c:y1( / plotdevice minp maxp minpoint maxpoint tkname ourset ilast i my ent1 orientation)
- (setq plotdevice "pdfFactory Pro (6.x)")
- (print "选择图框块" )
- (SETQ keytk (car (entsel)))
- (while (or (null keytk) (/= (cdr (assoc '0 (entget keytk))) "INSERT"))
- (SETQ keytk (car (entsel)))
- )
- (setq tkname (cdr (assoc '2 (entget keytk)) ))
- (alert (strcat "你要打印 \" " tkname "\"吗?" ))
- (setq papersize "A3")
- (setq plotstyle "monochrome.ctb")
- (command "ucs" "w")
- (print "选择您要打印的内容:")
- (SETQ ourset (ssget (list (cons 2 tkname))))
- (while (null ourset)
- (SETQ ourset (ssget (list (cons 2 tkname))))
- )
- (setq ilast (sslength ourset))
- (setq i 0)(setq iplot 0)
- (repeat ilast
- (setq my (ssname ourset i))
- (setq ent1 (entget my))
- (if (= (cdr (assoc '2 ent1) ) tkname)
- (progn
- (vla-getboundingbox (vlax-ename->vla-object my) 'minpoint 'maxpoint )
- (setq minp (vlax-safearray->list minpoint))
- (setq maxp (vlax-safearray->list maxpoint))
- (if ( > (- (car maxp)(car minp))(- (cadr maxp)(cadr minp))) (setq orientation "landscape") (setq orientation "portrait"))
- (command "-plot" "y" "model" plotdevice papersize "Millimeters" orientation
- "no" "w" minp maxp "fit" "c" "y" plotstyle "y" "n" "n" "n" "y")
- (setq iplot (1+ iplot))
- )
- )
- (setq i (1+ i))
- )
- (princ "\nThe total isú║")(princ iplot)
- (print "over!!!")
- (princ)
- )
- (defun c:y3( / plotdevice minp maxp minpoint maxpoint tkname ourset ilast i my ent1 orientation)
- ;(setq plotdevice "pdfFactory Pro (6.x)")
- (print "select keytk" )
- (SETQ keytk (car (entsel)))
- (while (or (null keytk) (/= (cdr (assoc '0 (entget keytk))) "INSERT"))
- (SETQ keytk (car (entsel)))
- )
- (setq tkname (cdr (assoc '2 (entget keytk)) ))
- (alert (strcat "Do you want to print \" " tkname "\"?" ))
- (setq papersize "")
- (setq plotstyle "")
- (command "ucs" "w")
- (print "Select what you want to print:")
- (SETQ ourset (ssget (list (cons 2 tkname))))
- (while (null ourset)
- (SETQ ourset (ssget (list (cons 2 tkname))))
- )
- (setq ilast (sslength ourset))
- (setq i 0)(setq iplot 0)
- (repeat ilast
- (setq my (ssname ourset i))
- (setq ent1 (entget my))
- (if (= (cdr (assoc '2 ent1) ) tkname)
- (progn
- (vla-getboundingbox (vlax-ename->vla-object my) 'minpoint 'maxpoint )
- (setq minp (vlax-safearray->list minpoint))
- (setq maxp (vlax-safearray->list maxpoint))
- (if ( > (- (car maxp)(car minp))(- (cadr maxp)(cadr minp))) (setq orientation "landscape") (setq orientation "portrait"))
- (command "-plot" "y" "model" "" "" "Millimeters" orientation
- "no" "w" minp maxp "fit" "c" "y" "" "y" "n" "n" "n" "y")
- (setq iplot (1+ iplot))
- )
- )
- (setq i (1+ i))
- )
- (princ "\nThe total isú║")(princ iplot)
- (print "over!!!")
- (princ)
- )
|