custom .pc3 not supported

custom .pc3 not supported

harimadhavan66
Participant Participant
2,231 Views
43 Replies
Message 1 of 44

custom .pc3 not supported

harimadhavan66
Participant
Participant

Hi Everyone, Good day to all, Im a beginner with lisp knowledge

 

I'm trying to customize a LISP routine to create PDFs using my own .pc3 and ctb file — specifically, I'm using "Foxit PDF Editor Printer.pc3". I tried replacing the default printer and setting a custom paper size, but the code isn’t working as expected.

 

 

(defun c:PDF ( / cm )

   (setq cm (getvar 'CMDECHO))

   (setvar 'CMDECHO 0)

   (command "_.-plot" "_y"

       (if (= 1 (getvar 'TILEMODE)) "Model" (getvar 'CTAB))

       "AutoCAD PDF (High Quality Print).pc3" "ARCH D (24.00 x 36.00 Inches)"

       "_M" "_L" "_N" "_E" "_F" "_C" "_Y" "monochrome.ctb" "_Y"

   )

   (if (= 1 (getvar 'TILEMODE))

       (command "_A")

       (command "_N" "_Y")

   )

   (command "_N" (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME))) "_Y" "_Y")

   (setvar 'CMDECHO cm)

   (princ)

)

(vl-load-com) (princ)

 

 

When I replace the default .pc3 file in the LISP code with my own (Foxit PDF Editor Printer.pc3), instead of plotting automatically, it starts asking for every input again — like paper size, plot area, etc

 

 As below 👇 

 

Command: PDF

Yes or No, please.

Don't use Esc while using a Lisp commandWrite the plot to a file [Yes/No] <N>: y

Command: MOPRINT

Yes or No, please.

Don't use Esc while using a Lisp commandWrite the plot to a file [Yes/No] <N>:

Save changes to page setup [Yes/No]? <N>

Proceed with plot [Yes/No] <Y>:

Effective plotting area: 903.11 wide by 603.25 high

Plotting viewport 1.

Effective plotting area: 792.73 wide by 577.98 high

Plotting viewport 2.

 

Also, it would be awesome if we could add a feature where each layout gets plotted using a name format and save location pulled from an Excel file. That would seriously save a ton of time and effort. Thanks in advance, friends!

0 Likes
Accepted solutions (3)
2,232 Views
43 Replies
Replies (43)
Message 2 of 44

Moshe-A
Mentor
Mentor

@harimadhavan66  hi,

 

i do not have Foxit printer driver  installed so could not really check

make some correction so use my version and on line# 5 make sure you replace the printer name to Foxit

 

enjoy

Moshe

 

(defun c:PDF ()
  (setvar 'CMDECHO 1)

 (command "_.-plot" "_Y" (getvar "ctab")
  "AutoCAD PDF (High Quality Print).pc3" ; replace this with: "Foxit PDF Editor Printer.pc3"
  "ARCH D (24.00 x 36.00 Inches)"
  "_M" "_L" "_N" "_E" "_F" "_C" "_Y"
  "monochrome.ctb" "_Y"
 )
  
 (if (= 1 (getvar 'TILEMODE))
  (command "_A")
  (command "_N" "_Y")
 )

 (command (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME))) "_Y" "_Y")
 
 (setvar 'CMDECHO 1)
 (princ)
)

 

 

 

Message 3 of 44

harimadhavan66
Participant
Participant

@Moshe-A  Hi, I have been tried that. But it shows 

 

Command: MOPRINT

 

Yes or No, please.

 

Don't use Esc while using a Lisp commandWrite the plot to a file [Yes/No] <N>:

 

Save changes to page setup [Yes/No]? <N>

 

Proceed with plot [Yes/No] <Y>:

 

Effective plotting area: 903.11 wide by 603.25 high

 

Plotting viewport 1.

 

Effective plotting area: 792.73 wide by 577.98 high

 

Plotting viewport 2.

0 Likes
Message 4 of 44

Moshe-A
Mentor
Mentor

@harimadhavan66 ,

 

Maybe Foxit printer driver has its own unique prompts, so to fix this run -PLOT manually 

and record each prompt and your reply than fix your lisp.

 

Moshe

 

Message 5 of 44

paullimapa
Mentor
Mentor

With custom pc3 files I’ve always encountered a problem even after getting all the prompts correctly that a plot file naming entry window would always popup interrupting the lisp. This even occurs after setting filedia to 0


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 44

paullimapa
Mentor
Mentor
Accepted solution

First of all, I added comments to the code and called the lisp command: PltPdfH

; PltPdfH generates pdf with AutoCAD PDF (High Quality Print).pc3
; OP: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-pc3-not-supported/td-p/13710861
(defun c:PltPdfH (/ cmdecho ctab filedia pdfname pltare pltctb pltdev pltlwt pltoff pltori pltppr pltscl pltsty pltuni pltupd)
  (vl-load-com)
  (setq cmdecho (getvar "cmdecho") ; save current settings
        filedia (getvar "filedia")
        ctab (getvar "ctab")
        pdfname (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-" ctab ".PDF") ; pdf with layout name appended 
  )
  (setvar "cmdecho" 0) ; suppress command echo
  (setvar "filedia" 0) ; suppress file selection window
  ; begin command line plot sequence
  (command "_.-PLOT"
    "_Yes" ; Detailed plot configuration? [Yes/No]
    ctab ; Enter a layout name or [?] ; or just return "" to accept current layout      
    "AutoCAD PDF (High Quality Print).pc3"; Enter an output device name or [?] ; "DWG To PDF.pc3" "AutoCAD PDF (General Documentation).pc3" "AutoCAD PDF (High Quality Print).pc3" "AutoCAD PDF (Smallest File).pc3" "AutoCAD PDF (Web and Mobile).pc3"
    "ARCH D (24.00 x 36.00 Inches)" ; Enter paper size or [?] ; unique for selected printer device
    "_Millimeters" ; Enter paper units [Inches/Millimeters] ; "_Inches"
    "_Landscape" ; Enter drawing orientation [Portrait/Landscape] ; "_Portrait"
    "_No" ; Plot upside down? [Yes/No]
    "_E" ; Enter plot area [Display/Extents/Layout/View/Window] "_D" "_L" "_W" "_V"
    "_F" ; Enter plot scale (Plotted Inches=Drawing Units) or [Fit] ; "1:1"
    "_C" ; Enter plot offset (x,y) <0.00,0.00>: ; "0,0" 
    "_Yes" ; Plot with plot styles? [Yes/No]
    "monochrome.ctb" ; Enter plot style table name or [?] (enter . for none)
    "_Yes" ; Plot with lineweights? [Yes/No]
  )
  (if (= 1 (getvar "tilemode")) ; chk space
   (command  ; then model
     "_A" ; Enter shade plot setting [As displayed/legacy Wireframe/legacy Hidden/Visual styles/Rendered] <As displayed>:
   )
   (command  ; else layout
    "_No" ; Scale lineweights with plot scale? [Yes/No]
    "_Yes" ; Plot paper space first? [Yes/No]
    "_No" ; Hide paperspace objects? [Yes/No]     
   )
  )    
  (command
    pdfname
    "_Yes" ; Save changes to page setup [Yes/No]
    "_Yes" ; Proceed with plot [Yes/No]
  )
  (setvar "filedia" filedia) ; restore original settings
  (setvar "cmdecho" cmdecho) 
  (princ) ; clean exit
)

I made the following changes:

1a) saved the current sys vars: cmdecho & filedia so can restore them back at end

1b) saved variable for current layout as ctab

1c) save pdf filename with current layout added at end:

  (setq cmdecho (getvar "cmdecho") ; save current settings
        filedia (getvar "filedia")
        ctab (getvar "ctab")
        pdfname (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-" ctab ".PDF") ; pdf with layout name appended 
  )

2) During initial plot sequence instead of checking tilemode to enter current layout:

(if (= 1 (getvar 'TILEMODE)) "Model" (getvar 'CTAB))

I just enter the current layout name using the save ctab variable:

    ctab ; Enter a layout name or [?] 

Or just go ahead and use enter to accept the current layout tab which is always returned as default:

; or just return "" to accept current layout  

3) This is a bit confusing as to what happens when running PLOT sequence in Model vs Layout:

   (if (= 1 (getvar 'TILEMODE))
       (command "_A")
       (command "_N" "_Y")
   )
   (command "_N" (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME))) "_Y" "_Y")

This should clarify the differences:

  (if (= 1 (getvar "tilemode")) ; chk space
   (command  ; then model
     "_A" ; Enter shade plot setting [As displayed/legacy Wireframe/legacy Hidden/Visual styles/Rendered] <As displayed>:
   )
   (command  ; else layout
    "_No" ; Scale lineweights with plot scale? [Yes/No]
    "_Yes" ; Plot paper space first? [Yes/No]
    "_No" ; Hide paperspace objects? [Yes/No]     
   )
  )    
  (command
    pdfname
    "_Yes" ; Save changes to page setup [Yes/No]
    "_Yes" ; Proceed with plot [Yes/No]
  )

These are the revisions I made for FoxIt with lisp command: PltFox:

; PltFox generates pdf with Foxit.pc3
; OP: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-pc3-not-supported/td-p/13710861
(defun c:PltFox (/ cmdecho ctab filedia pdfname pltare pltctb pltdev pltlwt pltoff pltori pltppr pltscl pltsty pltuni pltupd)
  (vl-load-com)
  (setq cmdecho (getvar "cmdecho") ; save current settings
        filedia (getvar "filedia")
        ctab (getvar "ctab")
        pdfname (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-" ctab ".PDF") ; pdf with layout name appended 
  )
  (setvar "cmdecho" 0) ; suppress command echo
  (setvar "filedia" 0) ; suppress file selection window
  ; begin command line plot sequence
  (command "_.-PLOT"
    "_Yes" ; Detailed plot configuration? [Yes/No]
    ctab ; Enter a layout name or [?] ; or just return "" to accept current layout      
    "Foxit PDF Editor Printer.pc3"  ; Enter an output device name or [?] ; "DWG To PDF.pc3" "Adobe PDF.pc3"
    "ARCH D" ; Enter paper size or [?] ; unique for selected printer device
    "_Millimeters" ; Enter paper units [Inches/Millimeters] ; "_Inches"
    "_Landscape" ; Enter drawing orientation [Portrait/Landscape] ; "_Portrait"
    "_No" ; Plot upside down? [Yes/No]
    "_E" ; Enter plot area [Display/Extents/Layout/View/Window] "_D" "_L" "_W" "_V"
    "_F" ; Enter plot scale (Plotted Inches=Drawing Units) or [Fit] ; "1:1"
    "_C" ; Enter plot offset (x,y) <0.00,0.00>: ; "0,0" 
    "_Yes" ; Plot with plot styles? [Yes/No]
    "monochrome.ctb" ; Enter plot style table name or [?] (enter . for none)
    "_Yes" ; Plot with lineweights? [Yes/No]
  )
  (if (= 1 (getvar "tilemode")) ; chk space
   (command  ; then model
     "_A" ; Enter shade plot setting [As displayed/legacy Wireframe/legacy Hidden/Visual styles/Rendered] <As displayed>:
   )
   (command  ; else layout
    "_No" ; Scale lineweights with plot scale? [Yes/No]
    "_Yes" ; Plot paper space first? [Yes/No]
    "_No" ; Hide paperspace objects? [Yes/No]     
   )
  )    
  (command
    "_Yes" ; Write the plot to a file [Yes/No] ; extra prompt may occur for custom pc3
    pdfname
    "_Yes" ; Save changes to page setup [Yes/No]
    "_Yes" ; Proceed with plot [Yes/No]
  )
  (setvar "filedia" filedia) ; restore original settings
  (setvar "cmdecho" cmdecho) 
  (princ) ; clean exit
)

1) The line with the printer name entry as you are already aware should now be:

    "Foxit PDF Editor Printer.pc3"  ; Enter an output device name or [?] ; "DWG To PDF.pc3" "Adobe PDF.pc3"

2) Since this is a different printer there are different named paper sizes so for D size it needs to be entered as:

    "ARCH D" ; Enter paper size or [?] ; unique for selected printer device

3) As @Moshe-A mentioned, when using a custom pc3 like FoxIt there is an extra prompt right before entering the plot file name:

  (command
    "_Yes" ; Write the plot to a file [Yes/No] ; extra prompt may occur for custom pc3
    pdfname
    "_Yes" ; Save changes to page setup [Yes/No]
    "_Yes" ; Proceed with plot [Yes/No]
  )

 But as I also mentioned in my previous reply to @Moshe-A when running lisp code using a custom pc3 like Foxit, though the pdf file name is given in the code, it will still get interrupted with a plot file name selection window making it not possible to run automatically:

paullimapa_0-1751664331194.png

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 7 of 44

harimadhavan66
Participant
Participant

@paullimapa Hi Sir, Thanks for the effort and time you have spend for it,

 

Now it works really super good, and now I can understand how things get worked. 

 

"Also, it would be awesome if we could add a feature where for every induvial DWG's each layout gets plotted using a name format and save location pulled from an Excel file. That would seriously save a ton of time and effort. Thanks in advance, friends!"

 

Is this possible to made via Lisp sir?...

0 Likes
Message 8 of 44

harimadhavan66
Participant
Participant

Before I switched to using a LISP solution, I was actually relying on the Publish command in AutoCAD. It worked well for the most part — but the main issue was that under the "PDF Preset: " option, it wouldn't show my custom PC3 file (Foxit PDF Editor Printer.pc3) (See snap-1). If that had worked properly, I wouldn't have needed to explore external options or scripting. Just wanted to say thanks to everyone who helped me along the way!.

 

Snap-1

 

harimadhavan66_0-1751674301876.png

 

0 Likes
Message 9 of 44

Sea-Haven
Mentor
Mentor

You can plot layouts by range using a lisp, say All or 2-5. this could be used in a script situation plotting all dwgs that you want you can send the resulting files to a single directory. See your post at Cadtutor.

 

You have the working lisp Plot command now by @paullimapa so can add open a dwg and load the lisp file and auto run via a script. Maybe even OBDX for other dwg's.

Message 10 of 44

harimadhavan66
Participant
Participant

I haven't try that yet. Is it need any hard coding knowledge?... And one more doubt is plot layout by range means?...

0 Likes
Message 11 of 44

paullimapa
Mentor
Mentor

Any reason for switching to using FoxIt when there are built-in AutoCAD PDF printers?

Also how were you able to accomplish this goal using PUBLISH command:

"...add a feature where for every induvial DWG's each layout gets plotted using a name format and save location pulled from an Excel file."

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 12 of 44

Sea-Haven
Mentor
Mentor

"Plot range" for a dwg with multiple layouts, you can plot ALL of them or plot layouts 2,3,4,5 only ie 2-5. My code uses a number not a layout name as that is to complicated.

 

Yes could read a Excel as well but that is complicated.

0 Likes
Message 13 of 44

harimadhavan66
Participant
Participant

I was originally using the Publish command to create individual PDF files from each layout — and it works fine in general.

 

But the issue is, Publish won’t let me use my custom .pc3 file (Foxit PDF Editor Printer.pc3). It only accepts default ones like DWG To PDF.pc3. That means I can't apply my customized settings for line thickness and other properties, which I’ve set up using my own .ctb file linked to that Foxit PC3.

 

Since Publish won’t cooperate with custom PC3s, I’m now looking for an AutoLISP solution instead. The goal is to automate PDF creation for each layout, using:

 

My Foxit PDF.pc3

My custom .ctb

 

And have each layout saved as a separate PDF, named something like JobNo_LayoutName.pdf

That’s why I’m moving away from Publish and exploring Lisp to get this done properly.

0 Likes
Message 14 of 44

paullimapa
Mentor
Mentor

Using saved Page Settings should allow you to specify custom ctb with any of the builtin AutoCAD pdf devices for publishing 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 15 of 44

harimadhavan66
Participant
Participant

Yeah but in case of .pc3 file it didn't get custom one sir. That's the problem.

0 Likes
Message 16 of 44

paullimapa
Mentor
Mentor

but as I mentioned the custom pc3 will popup the window to enter pdf filename interrupting the lisp automation


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 17 of 44

Sea-Haven
Mentor
Mentor

In plot lisp above  you set the printer and which ctb to use so that is not a problem. 

 

"monochrome.ctb" ; Enter plot style table name or [?] (enter . for none)

 

If you can explain more where you want the pdf's to be saved to then that can be added to the pdf name to be used. This code adds a pdf directory if not exist under the current dwg location. You can use it as an example or starting point of this task. If all the dwg';s are in one directory then it should be easy to make the pdf's

 

Part 2 is you can via lisp rejoin all the pdfs into a single pdf.

Message 18 of 44

harimadhavan66
Participant
Participant

I’ve set the default save location in my .pc3 file, so it doesn’t ask me where to save the PDF — that part works fine.

 

But the problem is, the PDF file name comes out random

 

If Publish could use my custom .pc3 file, it would make the whole process a lot easier and more flexible for making PDFs.

0 Likes
Message 19 of 44

paullimapa
Mentor
Mentor

PDF filename when using Publish should not come out random.

When PDF Publish Options Multi-sheet file toggle is unchecked the PDF file names are always the Drawing Name Followed by The Layout Name.pdf

paullimapa_0-1751688653814.png

paullimapa_1-1751688805628.png

When PDF Publish Options Multi-sheet file toggle is checked the PDF file name = Drawing name

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 20 of 44

harimadhavan66
Participant
Participant

It seems great and I'm already working with that but in publish command PDF preset option doesn't allow custom.pc3 file. I want to change with my own that what I'm trying sir.

 

With lisp I'm aim to achieve more similar behaviour like publish command. Or if possible to change the .pc3 file then I'll stick with publish command.

 

harimadhavan66_0-1751700572408.png

 

0 Likes