39
180
141
初露锋芒
(defun c:pdfpub (/ ob ss bn mn mx);; This was created by combining a multitude of different lisp routines by Lee Mac, RLX, Lee Ambrosius, Stephan BMR and howiez69 (vl-load-com) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) ;; Get the PlotConfigurations collection (setq plotCfgs (vla-get-PlotConfigurations doc)) ;; Check to see if the pagesetup already exists (setq plotCfg (vl-catch-all-apply 'vla-Item (list plotCfgs "PDFSetup"))) ;; If the page setup exists, the variable will be of type VLA-OBJECT (if (/= (type plotCfg) 'VLA-OBJECT) ;; Create a page setup for model or paper space accordingly (if (= (getvar "TILEMODE") 0) (setq plotCfg (vla-Add plotCfgs "PDFSetup" :vlax-false)) (setq plotCfg (vla-Add plotCfgs "PDFSetup" :vlax-true)) ) ) ;;(vla-put-Name plotCfg "PDFSetup") (vla-RefreshPlotDeviceInfo plotCfg) ;; Set the plot device (vla-put-ConfigName plotCfg "DWG To PDF.pc3") ;; Set the paper size (vla-put-CanonicalMediaName plotCfg "ARCH_full_bleed_C_(24.00_x_18.00_Inches)") ;; Set the plot units (inches, millimeters, pixels) (vla-put-PaperUnits plotCfg acInches) ;; Set what to plot ;; - If using acView, set the ViewToPlot property ;; - If using acWindow, call GetWindowToPlot (if (= (getvar "TILEMODE") 0) (progn (vla-put-PlotType plotCfg acLayout) ;; Set scale (vla-put-UseStandardScale plotCfg :vlax-true) (vla-put-StandardScale plotCfg ac1_1) ) (progn (vla-put-PlotType plotCfg acExtents) ;; Set scale (vla-put-UseStandardScale plotCfg :vlax-true) (vla-put-StandardScale plotCfg acScaleToFit) ) ) ;; Hide paperspace objects (vla-put-PlotHidden plotCfg :vlax-false) ;; Set the plot origin (setq origin (vlax-make-safearray vlax-vbDouble '(0 . 1))) (vlax-safearray-fill origin (list 0.5 0.5)) (vla-put-PlotOrigin plotCfg origin) ;; Set the plot rotation (vla-put-PlotRotation plotCfg ac0degrees) ;; Set viewport plot behavior (vla-put-PlotViewportBorders plotCfg :vlax-false) (vla-put-PlotViewportsFirst plotCfg :vlax-true) ;; Set lineweight behavior (vla-put-PlotWithLineweights plotCfg :vlax-true) (vla-put-ScaleLineweights plotCfg :vlax-true) ;; Set plot styles behavior (vla-put-PlotWithPlotStyles plotCfg :vlax-true) (vla-put-ShowPlotStyles plotCfg :vlax-true) ;; Center the plot on the page (if (= :vlax-false (vla-get-CenterPlot plotCfg)) (vla-put-CenterPlot plotCfg :vlax-true) ) (if (= (getvar "PSTYLEMODE") 0) (vla-put-StyleSheet plotCfg "acad.stb") (vla-put-StyleSheet plotCfg "TFC.ctb") ) ;; Assign the page setup to the current layout (vla-CopyFrom (vla-get-ActiveLayout doc) plotCfg) (vl-cmdf "UCS" "") (setq cnt 0) (if (not (setq folder (getfolder "Select folder to save views"))) (setq folder (getvar 'dwgprefix))(setq folder (strcat folder "\"))) (if (and (progn (initget "B") (setq ob (entsel "\nSelect Block/B for blockname: ")) (cond ((eq ob "B") (setq bn (getstring "\nEtner Block Name: ")) ) ((and (eq (type ob) 'LIST) (vlax-method-applicable-p (vlax-ename->vla-object (car ob)) 'getboundingbox)) (setq bn (cdr (assoc 2 (entget (car ob)))))))) (tblsearch "BLOCK" bn) bn (setq ss (ssget "_X" (list '(0 . "INSERT")'(410 . "Model")(cons 2 bn)))) )(progn (vla-zoomextents (vlax-get-acad-object)) (repeat (setq i (sslength ss)) (setq cnt (1+ cnt)) (vla-getboundingbox (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'mn'mx) (setq tmp (ssget "_C" (trans (vlax-safearray->list mx) 0 1) (trans (vlax-safearray->list mn) 0 1))) (vl-cmdf "_.-wblock" (strcat folder (itoa cnt) "-" (vl-filename-base (getvar 'dwgname)) ".dwg") "" "0,0" tmp "") (command "oops") )