limfx Posted June 2 Posted June 2 (edited) I am trying to write an automatic lisp printing CAD to PDF but the paragraph: (VLA-Plottofile (VLA-GET-Plot ADOC) Filename) Must wait for the end of the command line and appear the PDF file in the folder containing the same drawing to make the loop, which takes about 3 seconds. Also done (Foreach ...) appears:; Error: Automation Error. Description was not provided. Please help me fix this core, thank you! (prompt "Lisp is written by Limfx; Command: PFX") (vl-load-com) (defun c:PFX () (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (setq lyout (vla-get-activelayout adoc)) (setq cfgName "DWG TO PDF.PC3") (setq styleSheet "monochrome.ctb") (setq Aname "ISO_full_bleed_A3_(420.00_x_297.00_mm)") ; (vla-put-ConfigName lyout CfgName) (vla-put-StyleSheet lyout styleSheet) (vla-put-CanonicalMediaName lyout Aname) (vla-put-PaperUnits lyout acMillimeters) (vla-put-plotrotation lyout ac0degrees) (vla-put-PlotWithLineweights lyout :vlax-false) (vla-put-PlotWithPlotStyles lyout :vlax-true) (vla-RefreshPlotDeviceInfo lyout) ;; (setq lstp nil) (setq num 1) ;; (setq ss (ssget '((0 . "LWPOLYLINE") (-4 . "<OR") (70 . 1) (70 . 129) (-4 . "OR>") (90 . 4)))) (foreach si (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (vla-GetBoundingBox (vlax-ename->vla-object si) 'minpoint 'maxpoint) (setq pointTemp1 (vlax-make-safearray vlax-vbDouble '(0 . 1))) (vlax-safearray-put-element pointTemp1 0 (vlax-safearray-get-element minpoint 0)) (vlax-safearray-put-element pointTemp1 1 (vlax-safearray-get-element minpoint 1)) ;; (setq pointTemp2 (vlax-make-safearray vlax-vbDouble '(0 . 1))) (vlax-safearray-put-element pointTemp2 0 (vlax-safearray-get-element maxpoint 0)) (vlax-safearray-put-element pointTemp2 1 (vlax-safearray-get-element maxpoint 1)) ;;; (vla-SetWindowToPlot lyout pointTemp1 pointTemp2) (vla-put-PlotType lyout acWindow) (vla-put-CenterPlot lyout :vlax-true) (vla-put-StandardScale lyout acScaleToFit) ;; (setq num (1+ num)) (setq filename (strcat (getvar 'dwgprefix) "draw" (itoa num))) (vla-PlotToFile (vla-get-Plot adoc) filename) (LM:open (strcat filename ".pdf")) ) ;Thuc hien in (princ "limfx") );end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun LM:open ( target / rtn shl ) (if (and (or (= 'int (type target)) (setq target (findfile target))) (setq shl (vla-getinterfaceobject (vlax-get-acad-object) "shell.application")) ) (progn (setq rtn (vl-catch-all-apply 'vlax-invoke (list shl 'open target))) (vlax-release-object shl) (if (vl-catch-all-error-p rtn) (prompt (vl-catch-all-error-message rtn)) t ) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Edited June 3 by SLW210 Added Code Tags! Quote
exceed Posted June 3 Posted June 3 Please put the code in the <> window in the editor. Since it is not publish, you have to wait manually. I add this line for spool time after plot (command "delay" 3000) this value may vary depending on the each system. 1 Quote
BIGAL Posted June 3 Posted June 3 Have a look at this as an example code, no delays as hinted. But it is hard coded to suit our title block in layouts, we had different versions for PDF, A1 plotter, JPG etc. Tested on a project with 88 layouts. plotpdf.lspMulti GETVALS.lsp 1 Quote
limfx Posted June 3 Author Posted June 3 31 minutes ago, BIGAL said: Have a look at this as an example code, no delays as hinted. But it is hard coded to suit our title block in layouts, we had different versions for PDF, A1 plotter, JPG etc. Tested on a project with 88 layouts. plotpdf.lsp 1.15 kB · 33 downloads Multi GETVALS.lsp 2.96 kB · 64 downloads I don't want to use (command plot ...) because it is not suitable for optional operations. Is there a better way without using commands? Quote
limfx Posted June 3 Author Posted June 3 1 hour ago, exceed said: Please put the code in the <> window in the editor. Since it is not publish, you have to wait manually. I add this line for spool time after plot (command "delay" 3000) this value may vary depending on the each system. Established (command "delay" 15000) but the error still appears "; error: Automation Error. Description was not provided" Quote
exceed Posted June 3 Posted June 3 (edited) 27 minutes ago, limfx said: Established (command "delay" 15000) but the error still appears "; error: Automation Error. Description was not provided" Do the full path and file name consist only of English and numbers? Edited June 3 by exceed Quote
limfx Posted June 3 Author Posted June 3 9 minutes ago, exceed said: Do the full path and file name consist only of English and numbers? filename: "D:\\AUTOLISP\\SUUTAM\\draw2" Quote
Steven P Posted June 3 Posted June 3 7 hours ago, limfx said: I don't want to use (command plot ...) because it is not suitable for optional operations. Is there a better way without using commands? What optional operations do you use? Quote
SLW210 Posted June 3 Posted June 3 Please use Code Tags for your code. (Click the <> in the editor toolbar.) 1 Quote
BIGAL Posted June 3 Posted June 3 Sorry but why not use command ? We have been using this for years it will just flash before your eyes as it makes pdfs. I guess could convert command to vl but realistically don't think there will be any significant speed gain. Switching between layouts it takes like less than 1 second to make a pdf. That includes opening in the PDF viewer. For us it was a menu choice click the button and just watch it happen. Just tested on real dwg 15 layouts took 6 seconds. What is not fast enough about that ? 1 Quote
limfx Posted June 4 Author Posted June 4 14 hours ago, BIGAL said: Sorry but why not use command ? We have been using this for years it will just flash before your eyes as it makes pdfs. I guess could convert command to vl but realistically don't think there will be any significant speed gain. Switching between layouts it takes like less than 1 second to make a pdf. That includes opening in the PDF viewer. For us it was a menu choice click the button and just watch it happen. Just tested on real dwg 15 layouts took 6 seconds. What is not fast enough about that ? Thank you BIGAL. Using command plot is very fast. But (vla-PlotToFile) is very slow? So what was (vla-PlotToFile) created for? Is there any way to fix the above vla? Quote
exceed Posted June 5 Posted June 5 (edited) (setvar 'BACKGROUNDPLOT 0) It may be helpful to add this to the front of your code. Edited June 5 by exceed 1 Quote
limfx Posted June 5 Author Posted June 5 1 hour ago, exceed said: (setvar 'BACKGROUNDPLOT 0) It may be helpful to add this to the front of your code. Too fast and too convenient. Thank you so much! Wishing everyone many blessings! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.