Jump to content

Print in CAD to PDF errors slowly


limfx

Recommended Posts

Posted (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 by SLW210
Added Code Tags!
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

Posted (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 by exceed
Link to comment
Share on other sites

9 minutes ago, exceed said:

 

 

Do the full path and file name consist only of English and numbers?

filename: "D:\\AUTOLISP\\SUUTAM\\draw2"

Link to comment
Share on other sites

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?  

Link to comment
Share on other sites

Please use Code Tags for your code. (Click the <> in the editor toolbar.)

  • Like 1
Link to comment
Share on other sites

Sorry but why not use command ? We have been using this for years it will just flash before your eyes as it makes pdfs.

 

menu8.png.87aed6c8a46993749eca5c87f970b1cb.png

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 ?

  • Like 1
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Posted (edited)
(setvar 'BACKGROUNDPLOT 0)

 

It may be helpful to add this to the front of your code.

 

spacer.png

Edited by exceed
  • Like 1
Link to comment
Share on other sites

1 hour ago, exceed said:
(setvar 'BACKGROUNDPLOT 0)

 

It may be helpful to add this to the front of your code.

 

spacer.png

Too fast and too convenient. Thank you so much! Wishing everyone many blessings!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...