;;;;;;;修改后的程序;;;;;;;;;;; (defun c:test () (vl-load-com) (vl-cmdf "_.ucs" "_world") (setq clayout (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)) ) "Model" ) )
(vla-put-configname clayout "\\\\PC-127\\HP LJ8100 PS") ;此处应根据实际情况修改来设置打印设备 ;(vla-get-configname clayout )
(vla-put-centerplot clayout :vlax-true) (vla-put-CanonicalMediaName clayout "A4") (vla-put-plotwithplotstyles clayout :vlax-true) (vla-put-standardscale clayout acscaletofit) (setq cplot (vla-get-plot (vla-get-activedocument (vlax-get-acad-object)))) ;--------------------- (vla-put-paperunits clayout acMillimeters) (vla-getpapersize clayout 'width 'height) (if (> height width) (setq pmax height pmin width) (setq pmax width pmin height) ) ;---------------------
(setq number 5 ) (setq i 0 points '() pointsT '()) (while (< i number) (setq pt1 (getpoint "\n 1st point :")) (setq pt2 (getcorner pt1 "\n 2st point :")) (setq pointsT (list pt1 pt2)) (setq points (cons pointsT points)) (setq i (+ i 1)) ) ; (setq points (reverse points)) (setq i 0) (while (< i number) (setq pt1 (car (nth i points)) pt2 (cadr (nth i points)) ) (setq p1 (vlax-make-safearray vlax-vbdouble '(1 . 2))) (vlax-safearray-fill p1 (list (car pt1) (cadr pt1)) ) (setq p2 (vlax-make-safearray vlax-vbdouble '(1 . 2))) (vlax-safearray-fill p2 (list (car pt2) (cadr pt2)) ) ; (vla-setwindowtoplot clayout p1 p2) (vla-put-plottype clayout acwindow ) ; ;--------------- (if (< (car pt1) (car pt2)) (setq minx (car pt1)) (setq minx (car pt2)) ) (if (< (cadr pt1) (cadr pt2)) (setq miny (cadr pt1)) (setq miny (cadr pt2)) )
(setq dx (abs (- (car pt1) (car pt2) )) dy (abs (- (cadr pt1) (cadr pt2) )) ) (if (> dx dy) (setq mmax dx mmin dy ) (setq mmax dy mmin dx ) ) (setq ratio_max (/ mmax pmax) ratio_min (/ mmin pmin) )
(if (> ratio_max ratio_min) (progn (setq ratio ratio_max ) (setq offsetx (- pmin (/ mmin ratio)) ) (setq offsetx (/ offsetx 2.0) offsety 0) ) (progn (setq ratio ratio_min ) (setq offsety (- pmax (/ mmax ratio)) ) (setq offsety (/ offsety 2.0) offsetx 0) ) )
(setq newValue (vlax-make-safearray vlax-vbDouble '(1 . 2))) (vlax-safearray-fill newValue (list offsetx offsety ) ) (vla-put-PlotOrigin clayout newValue) ;--------------- ; (if (> (abs (- (car pt1) (car pt2))) (abs (- (cadr pt1) (cadr pt2))) ) (vla-put-plotrotation clayout ac90degrees) (vla-put-plotrotation clayout ac180degrees) ) ; (princ "\n preview.....") ; (vla-displayplotpreview cplot acfullpreview) ; (setq i (+ i 1)) ) ; (vl-cmdf "_.ucs" "_P") (prin1) );主程序结束 |