Jump to content

PDF to predefind folder


tive29

Recommended Posts

The below lisp PDF to current drawing location folder.

 

How to save to to another folder (eg, d:\PDF) or document folder

 

(defun C:PP (/ fnm)

(if (setq fnm (getfiled "Specify Save Location" "" "pdf" 1))
(progn

(command "tilemode" "0")
(command "-plot" "y" "" "Dwg To PDF.pc3" "ISO expand A4 (210.00 x 297.00 MM)" "M" "P" "N" "W" "" "" "1:1" "C" "Y" "Myplotstyle.ctb" "Y" "N" "N" "N" fnm "N" "Y")
)
 )
 )

Link to comment
Share on other sites

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • tive29

    11

  • FranknBeans

    8

  • BIGAL

    6

  • SLW210

    1

This creates a pdf directory below the dwg folder

 

; check that pdf directory exists
(setq dwgpre (strcat (getvar "dwgprefix") "\pdf"))
(if (= (vl-file-directory-p dwgpre) nil)
(vl-mkdir dwgpre)
)

(setq pdfname (strcat dwgpre "\\" dwgname "-" (getvar "ctab") ".pdf" ))
y" "Designlasercolour.ctb" "Y"	"n" "n" "n" pdfName "N" "y"

Link to comment
Share on other sites

This creates a pdf directory below the dwg folder

 

; check that pdf directory exists
(setq dwgpre (strcat (getvar "dwgprefix") "\pdf"))
(if (= (vl-file-directory-p dwgpre) nil)
(vl-mkdir dwgpre)
)

(setq pdfname (strcat dwgpre "\\" dwgname "-" (getvar "ctab") ".pdf" ))
y" "Designlasercolour.ctb" "Y"    "n" "n" "n" pdfName "N" "y"

 

How to combine this with my lisp?

Link to comment
Share on other sites

Edited to this but getting an error

 

(defun C:PP (/ pdfName)

(setq dwgpre (strcat (getvar "dwgprefix") "\pdf"))
(if (= (vl-file-directory-p dwgpre) nil)
(vl-mkdir dwgpre)
)

(setq pdfname (strcat dwgpre "\\" dwgname "-" (getvar "ctab") ".pdf" ))

(command "tilemode" "0")
(command "-plot" "y" "" "Dwg To PDF.pc3" "ISO expand A4 (210.00 x 297.00 MM)" "M" "P" "N" "W" "" "" "1:1" "C" "Y" "Myplotstyle.ctb" "Y" "N" "N" "N" pdfName "N" "Y")
)

Command: pp

; error: bad argument type: stringp nil

Link to comment
Share on other sites

Hi, try this..

(defun c:pp (/ fnm fl)
(while (null fnm)
 (or (snvalid (setq fnm (getstring "\nFilename: ")))
     (progn (princ "\n** Invalid Filename **")
            (setq fnm nil)
     )
 )
)
(initget "D Documents")
(setq fl (getkword "\nSpecify Save Location [D/DOcuments] <Other>: "))
(cond 
 ((eq fl "D")(setq fnm (strcat "D:\\pdf\\" fnm ".pdf")))
 ((eq fl "Documents")(setq fnm (strcat (getenv "userprofile") "\\My Documents\\" fnm ".pdf")))
 ( T (setq fnm (getfiled "Specify Save Location" fnm "pdf" 1)))
)
(command "tilemode" "0")
(command "-plot" "y" "" "Dwg To PDF.pc3" "ISO expand A4 (210.00 x 297.00 MM)" "M" "P" "N" "W" "" "" "1:1" "C" "Y" "Myplotstyle.ctb" "Y" "N" "N" "N" fnm "N" "Y")
(princ)
)

you can have any number of locations defined in the 'cond' set

Link to comment
Share on other sites

oops, can't seem to edit my previous post but change the 3rd line to the below to allow for spaces in the filename.

  (or (snvalid (setq fnm [color=red](vl-string-trim " " [/color](getstring [color=red]T[/color] "\nFilename: ")))[color=red])[/color]

Link to comment
Share on other sites

Hi FranknBeans.

When I ran the LISP, it has this error. It also did not create any PDF

 

At the 2nd line, "FILENAME:" it waited on me to enter a file name.

Next, "Specify Save Location [D/DOcuments] :" pressing "d" or "DO" or just enter have the same error.

 

I just want the lisp to directly save the PDF base on the original filename into the predefined folder without any intervention from the user.

 

Command: pp

 

Filename: test

 

Specify Save Location [D/DOcuments] : d

tilemode

Enter new value for TILEMODE : 0

Command: -plot Detailed plot configuration? [Yes/No] : y

Enter a layout name or [?] : Enter an output device name or [?] : Dwg To PDF.pc3 Enter paper size or [?] : ISO expand A4 (210.00 x 297.00 MM) Enter paper units [inches/Millimeters] : M Enter drawing orientation [Portrait/Landscape] : P Plot upside down? [Yes/No] : N Enter plot area [Display/Extents/Layout/View/Window] : W Enter lower left corner of window : Enter upper right corner of window :

Command: 1:1 Unknown command "1:1". Press F1 for help.

 

Command: C Unknown command "C". Press F1 for help.

 

Command: Y Unknown command "Y". Press F1 for help.

 

Command: test.ctb Unknown command "CTB". Press F1 for help.

 

Command: Y Unknown command "Y". Press F1 for help.

 

Command: N Unknown command "N". Press F1 for help.

 

Command: N Unknown command "N". Press F1 for help.

 

Command: N Unknown command "N". Press F1 for help.

 

Command: c:\pdf\test.pdf Unknown command "PDF". Press F1 for help.

 

Command: N Unknown command "N". Press F1 for help.

 

Command: Y Unknown command "Y". Press F1 for help.

 

Command:

Link to comment
Share on other sites

Is there a way to have command line for EXPORT or EXPORTPDF?

 

It just ends after pressing "YES" to "Detailed plot configuration? [Yes/No]?"

 

Command: -EXPORT

Enter file format [Dwf/dwfX/Pdf]

Enter plot area [Current layout/All layouts]:

Detailed plot configuration? [Yes/No] : Y

Command:

 

I intend to run it in a LISP routine.

Link to comment
Share on other sites

The plot question/answer sequence was copied & pasted from your original post, it looks like there is no pause to allow a window selection.

If you just want it to use the drawing name & save automatically (to c:\pdf\) the following should work..

(defun c:pp ()
(command "tilemode" "0")
(command "-plot" "y" "" "Dwg To PDF.pc3" "ISO A4 Custom (297.00 x 210.00 MM)" "M" "P" "N" "W" [color="red"]PAUSE PAUSE[/color] "1:1" "C" "Y" "orora.ctb" "Y" "N" "N" "N" 
(strcat "C:\\pdf\\" (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4)) ".pdf")
"N" "Y")
)

Link to comment
Share on other sites

Here is the complete bit and like Franknbeans has the two window points coded in.

 

   (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" "Designlasercolour.ctb" "Y" "n" "n" "n" pdfName "N" "y"
   )

Link to comment
Share on other sites

The plot question/answer sequence was copied & pasted from your original post, it looks like there is no pause to allow a window selection.

If you just want it to use the drawing name & save automatically (to c:\pdf\) the following should work..

(defun c:pp ()
(command "tilemode" "0")
(command "-plot" "y" "" "Dwg To PDF.pc3" "ISO A4 Custom (297.00 x 210.00 MM)" "M" "P" "N" "W" [color="red"]PAUSE PAUSE[/color] "1:1" "C" "Y" "orora.ctb" "Y" "N" "N" "N" 
(strcat "C:\\pdf\\" (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4)) ".pdf")
"N" "Y")
)

 

doh! I left in my paper size & .ctb file from testing, change these to your own values

 

Hi. To clarify

 

1) As shown in my last post on the errors, notice that it was based on my own setting & values.

 

2) It has nothing to do with "" "". As in the first post, I indicated "" "" such that it will base on individual drawing original windowed points.

Since that lisp work for every drawings. Except of I need the PDF to go to another folder

 

As an experiment, I use the values 0,0 0,0 to see if it worked.

This is the lisp

(defun c:pp (/ fnm fl)
(while (null fnm)
 (or (snvalid (setq fnm (vl-string-trim " " (getstring T "\nFilename: "))))
     (progn (princ "\n** Invalid Filename **")
            (setq fnm nil)
     )
 )
)
(initget "D Documents")
(setq fl (getkword "\nSpecify Save Location [D/DOcuments] <Other>: "))
(cond 
 ((eq fl "D")(setq fnm (strcat "c:\\pdf\\" fnm ".pdf")))
 ((eq fl "Documents")(setq fnm (strcat (getenv "userprofile") "\\My Documents\\" fnm ".pdf")))
 ( T (setq fnm (getfiled "Specify Save Location" fnm "pdf" 1)))
)
(command "tilemode" "0")
(command "-plot" "y" "" "Dwg To PDF.pc3" "ISO expand A4 (210.00 x 297.00 MM)" "M" "P" "N" "W" "0,0" "0,0" "1:1" "C" "Y" "test.ctb" "Y" "N" "N" "N" fnm "N" "Y")
(princ)
)

 

The errors are still the same.

 

Command: pp

 

Filename: test

 

Specify Save Location [D/DOcuments] :

tilemode

Enter new value for TILEMODE : 0

Command: -plot Detailed plot configuration? [Yes/No] : y

Enter a layout name or [?] : Enter an output device name or [?] : Dwg To PDF.pc3 Enter paper size or [?] : ISO expand A4 (210.00 x 297.00 MM) Enter paper units [inches/Millimeters] : M Enter drawing orientation [Portrait/Landscape] : P Plot upside down? [Yes/No] : N Enter plot area [Display/Extents/Layout/View/Window] : W Enter lower left corner of window : 0,0 Enter upper right corner of window : 0,0

Command: 1:1 Unknown command "1:1". Press F1 for help.

 

Command: C Unknown command "C". Press F1 for help.

 

Command: Y Unknown command "Y". Press F1 for help.

 

Command: test.ctb Unknown command "CTB". Press F1 for help.

 

Command: Y Unknown command "Y". Press F1 for help.

 

Command: N Unknown command "N". Press F1 for help.

 

Command: N Unknown command "N". Press F1 for help.

 

Command: N Unknown command "N". Press F1 for help.

 

Command: C:\Windows\system32\test.pdf Unknown command "PDF". Press F1 for help.

 

Command: N Unknown command "N". Press F1 for help.

 

Command: Y Unknown command "Y". Press F1 for help.

 

Command:

 

Is there anything else wrong with the lisp?

 

Thanks

Link to comment
Share on other sites

2 things "0,0" "0,0" & "1:1"

Try (getvar "extmin") (getvar "extmax")

and "1=1"

 

I have around 6 lisps for plotting and they have always worked but we have fixed size title blocks so window is the preferred option.

Link to comment
Share on other sites

Thanks BIGAL. The problem is when the drawing was created by someone years back, there are a few difference size title blocks in 1 layout.

Hence, I cannot use (getvar "extmin") (getvar "extmax").

 

There are over hundreds of drawings like this.

 

If the position are the same, at least I can use the same window coordinates, but no, they are all at different location between these drawings.

 

The only saving grace,in the drawings, to lessen my pain of printing, is the plot area in the plot setup is WINDOWED CORRECTLY to the drawing that I need to PDF.

 

So When I PDF, I need to base on my PDF settings accordingly (as per my LISP in the 1st post eg, paper size, plotstyle.....) EXCEPT the plot area.

 

Any solution?

Link to comment
Share on other sites

Ok gets even more involved yes and yes but lots more if and buts, you can do multiple title blocks in one space even down too they are all different, look at my recent post. You can find a title BLOCK get its info and then plot it. Problem is you want around 5 different programs bundled into 1 a do all. It comes down to just working on one problem at a time. I have 16 different plot routines that have been from time to time more recently that has been cut down in our daily stuff to around 4. Some custom ones are used as required.

Link to comment
Share on other sites

2) It has nothing to do with "" "". As in the first post, I indicated "" "" such that it will base on individual drawing original windowed points.

Since that lisp work for every drawings. Except of I need the PDF to go to another folder

 

If you have a lisp that works, all you need to do is take out the part where it asks you for a filename and replace the variable (fnm) in the plot answers with the full path & filename that you want - see post #9 of this thread for an example, can you confirm you tried this code?

Link to comment
Share on other sites

If you have a lisp that works, all you need to do is take out the part where it asks you for a filename and replace the variable (fnm) in the plot answers with the full path & filename that you want - see post #9 of this thread for an example, can you confirm you tried this code?

 

I revised it to my settings. It did save the PDF but

1) No folder is created.

2) Instead it save the PDF to Document file

3) the PDF name is saved as N instead of the fie name

 

(defun c:pp () (command "tilemode" "0") (command "-plot" "y" "" "Dwg To PDF.pc3" "ISO expand A4 (210.00 x 297.00 MM)" "M" "P" "N" "W" "" "" "1:1" "C" "Y" "MyStyle.ctb" "Y" "N" "N" "N"      (strcat "C:\\pdf\\" (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4)) ".pdf")     "N" "Y") )

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