Thanks again Henrique,
I had already found another similar approach that I tested isolated and it worked.
By the way, when I want to integrate into the routine it fails. I tried with your suggestions and is not working neither, I think I am doing something wrong in the function call.
Here is my current approach:
;; Function to show a dialog box with the msg passed by parameter
;; mode 0 the message is shown at the command bar
;; mode 1 the message is shown as a popup
(defun display-msg (msg mode / )
(if (= mode 0)
(prompt (strcat "\n" msg))
(alert msg)
)
(princ)
)
;; filename = filename of file to test
;; Returns T if specified file is open
(defun _FileOpen-p ( filename / f )
(if (setq f (open filename "a"))
(close f)
t
)
)
(defun CREATE-PDF-LAYERS(/)
... more code ...
(setq temp (strcat dir_name dwgname "-" name ".pdf"))
(setq pdffile (vl-string-subst "PLF" "INT" temp))
;; Close the file if it is opened
(if (= (_FileOpen-p pdffile) "T")
(progn
(display-msg "Open PDF")
(setvar "cmddia" 1)
(setvar "filedia" 1)
(setq DWGNAME nil
LEN nil
NAME nil
PLOTTABLIST nil
pdffile nil)
(exit)
)
)
...more code ...
)
and the command out i get:
1 layer deleted.
Command: tilemode
Enter new value for TILEMODE <0>: 0
Command: -plot Detailed plot configuration? [Yes/No] <No>: Y
Enter a layout name or [?] <MP-PR>: MP-CM Regenerating layout.
Regenerating model - caching viewports.
Enter an output device name or [?] <DWG To PDF.pc3>: Dwg To PDF.pc3
Enter paper size or [?] <ANSI A (11.00 x 8.50 Inches)>: ISO full bleed A3 (297.00 x 420.00 MM)
Enter paper units [Inches/Millimeters] <Millimeters>: M
Enter drawing orientation [Portrait/Landscape] <Landscape>: L
Plot upside down? [Yes/No] <No>: N
Enter plot area [Display/Extents/Layout/View/Window] <Extents>: E
Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1=1>: 1:1
Enter plot offset (x,y) or [Center] <Center>: C Plot with plot styles? [Yes/No] <Yes>: Y
Enter plot style table name or [?] (enter . for none) <OBS_STB.stb>: OBS_STB.stb
Plot with lineweights? [Yes/No] <Yes>: Y Scale lineweights with plot scale? [Yes/No] <No>: N
Plot paper space first? [Yes/No] <No>: N Hide paperspace objects? [Yes/No] <No>: N
Enter file name <C:\Users\jvelasco\Desktop\CAD test\R38 DES MP CAMINT 01-13 - Standard\R38 DES MP CAMINT 01-13-MP-CM.pdf>: O:\Cad\Operators Files - Re\OBS Acad Tools\CAD Dep Stuff\Temporal Batch Folder\R38 DES MP CAMPLF 01-13-MP-CM.pdf
Enter file name <C:\Users\jvelasco\Desktop\CAD test\R38 DES MP CAMINT 01-13 - Standard\R38 DES MP CAMINT 01-13-MP-CM.pdf>: Y
Save changes to page setup [Yes/No]? <N> Y
Proceed with plot [Yes/No] <Y>: tilemode
Yes or No, please.
; error: Function cancelled
The command keeps waiting for the "Proceed plot"question.
I tried similar apporach with the function you suggested, and I still can't get it.
Can you see my mistake?
Thank you so much, I am starting to feel an autolisp beginner thanks to your assistance.