Jump to content

Recommended Posts

Posted

Hi all,

 

Got myself something odd.

In my plot-config the 'Show results in viwer' is turned on, wich should open de PDF after creation.

 

When i use the code below:

(command "PLOT" "Y" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" (strcat (getvar "DWGPREFIX") "TEST.PDF") "" "Y")

 

The PDF does not open after creation.

 

When i use the code manualy, it DOES open the PDF as expected...

 

Is there some variable im missing?

Manual it works, with LISP it doesnt...

Posted

You can use the starapp function to open the desired file and here is an example.

(startapp "explorer" "C:\\Users\\Tharwat\\Downloads\\Test.pdf")

Note: you need to have the path with the same format of back slashes or one forward slash instead as you like.

Posted

If you are using this in a routine you might want to add in a few details - takes a moment to add them once and will be there each time.

 

A quick check first that you are getting a PDF but just without the preview.

 

I copied and pasted your line of code and had to add in "dwg to PDF"  for the plotter (add your own preferences) - the sheet I was using didn't have a plotter assigned to it - but afterwards it did it as expected, with a preview. Might be something simple like that.

 

(command "PLOT" "Y" "" "Dwg to PDF" ""......

 

 

 

 

For my PDF routines I tend to specify everything earlier in the routine rather than using "" and put in the variables in the command line - it reduces the number of errors and covers things like the page setup not being set up

  • Agree 1
Posted (edited)

To build on what Steven said. When things are not working right using command.  use the command manualy by adding a - infront and step thought the command line entrys and see what you need to change.

 

-plot

 

Also at my old job we had to print the drawing with a revision number at the end. Made this lisp would always print to Documents and then copy the file back to where the dwg was.

 

**Be aware that their is a line in here to delete the PDF your replacing.  (vl-file-delete fp)

 

;;----------------------------------------------------------------------------;;
;; Copy Printed PDF in My Documents to Drawing location.
;; http://www.lee-mac.com/open.html
(defun C:CP (/ path fn fs fp)
  (vl-load-com)
  (setq path (strcat (getvar 'DWGPREFIX))
        fn (vl-filename-base (getvar 'dwgname))
        fs (strcat (getenv "userprofile") "\\Documents\\" fn ".pdf")
        ;fn (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 6))  ;remove the minor Revision number from name
        fp (strcat path fn ".pdf")
  )
  (if (= (findfile fs) nil)
    (progn
      (prompt "NO PDF TO COPY")
      (QUIT)
    )
  )
  (cond
    ((findfile fp)
      (setq reply (ACET-UI-MESSAGE (strcat "\nDo you want to update PDF \"" fn "\"") "Existing PDF" (+ Acet:YESNO Acet:ICONWARNING)))
      (if (= reply 6)  ;Yes
        (progn
          (vl-file-delete fp)
          (vl-file-copy fs fp)
          (LM:Open fp)
        )
      )
    )
    (t
      (progn
        (vl-file-copy fs fp)
        (LM:Open fp)
      )
    )
  )
  (princ)
)
;;----------------------------------------------------------------------------;;
;; A wrapper for the 'Open' method of the Shell Object
;; f (target) - [int/str] File, folder or ShellSpecialFolderConstants enum
;; http://www.lee-mac.com/open.html
(defun LM:open (f / rtn shl)
  (if (and (or (= 'int (type f)) (and (= (type f) 'STR) (setq f (findfile f))))
        (setq shl (vla-getinterfaceobject (vlax-get-acad-object) "shell.application"))
      )
    (progn
      (setq rtn (vl-catch-all-apply 'vlax-invoke (list shl 'open f))) (vlax-release-object shl)
      (if (vl-catch-all-error-p rtn) (prompt (vl-catch-all-error-message rtn)) t)
    )
  )
)

 

Edited by mhupp
  • Like 1
Posted

Hi All, ive been testing with all suggestions.

 

Seems like my 'BATCH' function showhow disables the feature.

When i make a single plot of a layout it works fine now, when i batch, it fails.

 

Looks like a timing issue.

Didnt get it fixed yet. Working on that! 😄

 

Atleast i know where to look, and its not a variable or sometinh.

Posted

For batch plotting PDFs I use a page with preview disabled - it is a pain batch plotting many drawings and each brings up a preview, slows things down a lot - what is happening to you sounds like a bonus! .However it doesn't explain why it is not doing as it should

 

If you batch plot a single drawing does this bring up the preview though?

 

 

 

If I get chance late I'll do a test with my batch routine, see what it does for me

Posted

Odd, most of my plotting to PDF is without a preview, so some drawings do the preview and some don't, can't work out quite why either. It will come to me sometime.

 

I was just going to post this snippet, I find this easier to follow than a sting of ""s and of course, each of the variables you set here can be linked to a function or something to make it specific to a drawing, project, or whatever

 

 

(setq 
  detailedplotconfiguration "Y"
  layoutname "Layout1"
  plottername "Dwg to PDF"
  papersize ""
  paperunits ""
  orientation "Landscape"
  plotupsidedown ""
  plotarea ""
  plotscale ""
  plotoffset ""
  plotwithplotstyles ""
  plotstyletablename ""
  plotwithlineweights ""
  ScaleLineweights "" ;;Not in Model Space
  ShadePlotSettings "" ;;Not in Model Space
  HidePaperSpaceObjects "" ;;Not in Model Space
  filepathname (strcat (getvar "DWGPREFIX") "TEST.PDF")
  saveplotsettings "N"
  proceedwithplot "Y"
)
(command "-plot"
  detailedplotconfiguration
  layoutname
  plottername
  papersize
  paperunits
  orientation
  plotupsidedown
  plotarea
  plotscale
  plotoffset
  plotwithplotstyles
  plotstyletablename
  plotwithlineweights
  ScaleLineweights
  ShadePlotSettings
  HidePaperSpaceObjects
  filepathname
  saveplotsettings
  proceedwithplot
)

 

Posted

@Steven P, glad im not the only one.

but when i use the code manualy, it works like a charm.

When fired with a LISP-command, is refuses.

  • Like 1
Posted
4 hours ago, Aftertouch said:

but when i use the code manualy, it works like a charm. When fired with a LISP-command, is refuses.

 

I have had many issues with command function over the years acting not quite the same way when you type it out manually. Can't remember exactly what (command it was but found out that vla-sendcommand with the same parameters worked like when typing it manually.

 

Also try vl-cmdf tho i don't know if their is a difference between that function and command.

 

(defun c:al-sendcommand ()
  (vl-load-com)
  (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
  (vla-SendCommand thisdrawing (strcat "PLOT" "Y" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" (strcat (getvar "DWGPREFIX") "TEST.PDF") "" "Y"))
  (princ)
);defun

(vl-cmdf "PLOT" "Y" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" (strcat (getvar "DWGPREFIX") "TEST.PDF") "" "Y")

 

if still not working look into vla-PlotToFile lisp.

  • Like 1
Posted

Using this in a loop plot 88 layouts, the Acrobat pdf opens then gives an error message about 20 pdf's in but keeps going creating all 88 pdf's.

 

   (COMMAND "-PLOT"  "Y"  "" "DWG To PDF"
	       "Iso full bleed A3 (420.00 x 297.00 MM)" "m" "LANDSCAPE"  "N"   "W"  "-6,-6" "807,560" "1=2"  "C"
	       "y" "Acad.ctb" "Y"	"n" "n" "n" pdfName "N" "y"
    )

 

  • Like 1

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...