Turning off last plotted folder, so default plot to file location is always used.

Turning off last plotted folder, so default plot to file location is always used.

Kieran.ODonnellP4HWV
Participant Participant
1,826 Views
15 Replies
Message 1 of 16

Turning off last plotted folder, so default plot to file location is always used.

Kieran.ODonnellP4HWV
Participant
Participant

Is there a way to turn off the 'last folder plotted' feature, so the default location to plot to file will always be used when plotting?

 

I am using the following LISP to set the default plot to file location to the "DWGPREFIX" and this works perfectly until I actually plot because after I plot once the next plot will bypass the default location and plot to the most recent plot location.

 

(defun c:PPATH ()
(command "PlotToFilePath" (getvar "DWGPREFIX"))
(princ "\nPlot path now matches Drawing path.")
(princ)
)
(command "PlotToFilePath" (getvar "DWGPREFIX"))

 

Thank you in advance for your help.

0 Likes
Accepted solutions (1)
1,827 Views
15 Replies
Replies (15)
Message 2 of 16

john.uhden
Mentor
Mentor

@Kieran.ODonnellP4HWV 

I do something the opposite at work in a plot reactor, but I'm stuck at home with a positive COVID test.  Please remind me to check on Monday.

John F. Uhden

0 Likes
Message 3 of 16

Sea-Haven
Mentor
Mentor

There is lots of plot lisps out there we had printer, pdf and plotter, with options all from a menu select then watch them all come out.

 

We had make a new folder called pdf under the dwg folder and all pdfs went there. Easy to find and did not clogg up the dwg directory. 

 

If you have code already post it.

0 Likes
Message 4 of 16

Moshe-A
Mentor
Mentor

@Kieran.ODonnellP4HWV  hi,

 

Add this code your acad.lsp or acaddoc.lsp (or any other lsp file of your choice, just make sure it is in appload startup suite) each time you invoke plot, plottofilepath will be set to the current dwg folder.

 

enjoy

moshe

 

 

 

(defun p2p:OnCommandWillStart (react cmdName^)
 (if (wcmatch (car cmdName^) "PLOT,-PLOT")
  (setvar "plottofilepath" (getvar "dwgprefix"))
 )
)

(cond
 ((not p2p:cmdReact)
  (setq p2p:cmdReact (vlr-command-reactor nil '((:vlr-commandWillStart . p2p:OnCommandWillStart))))
 )
 ((not (vlr-added-p p2p:cmdReact))
  (vlr-add p2p:cmdReact)
 )
); cond

 

 

 

 

Message 5 of 16

john.uhden
Mentor
Mentor

@Kieran.ODonnellP4HWV 

Maybe what I do may help by example:

(defun @get_plotpath ( / regpath path)
  (setq regpath (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\General"))
  (setq path (vl-registry-read regpath "PLOTTOFILEPATH"))
)
(defun @set_plotpath (path / regpath)
  (setq regpath (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\General"))
  (vl-registry-write regpath "PLOTTOFILEPATH" path)
)

(defun @Uhden_command_started (Reactor Info / Reaction Active path)
  (setq Reaction (vlr-current-reaction-name)
        Active   (car Info)
  )
  ;;(princ "\nReaction: ")(prin1 Reaction)
  ;;(princ "  Active: ")(prin1 Active)
  ;;(princ "\n")
  (and
   (= Reaction :vlr-commandWillStart)
   (wcmatch Active "PLOT")
   (setq path (@set_plotpath))
   (not (alert (strcat "PLOTPATH set to:\n\n" path)))
  )
)
(if (= (type Uhden_editor_reactor) 'VLR-Editor-Reactor)
   (progn
      (if (not (vlr-added-p Uhden_editor_reactor))
         (vlr-add Uhden_editor_reactor)
      )
   )
   (setq Uhden_editor_reactor
      (vlr-editor-reactor "Uhden Editor Reactor"
        '(
            (:vlr-commandWillStart . @Uhden_command_started)
         )
      )
   )
)

 Only problem is that after a few successes in a row, AutoCAD tends to ignore my reactor and reverts to an earlier path.  That's probably because I'm running SDI=0 and have several drawings open at the same time.

John F. Uhden

0 Likes
Message 6 of 16

Kieran.ODonnellP4HWV
Participant
Participant

Hi @Moshe-A ,

 

Thank you for your help. The issue I have is not setting the plottofilepath. The code I posted initially is just a manual version of what you sent through. The issue is I always have multiple drawings open and I plot often depending on the day 20-40 times roughly. The plottofilepath is void after I plot one time because CAD defaults to the previous plot location unless I close and open CAD each time I want to plot a drawing.  

 

Each one of the drawings sits deep in subfolders and I spend a decent amount of time navigating through our folder system between each plot which is time consuming and I am trying to increase efficiency here. The part I am trying to figure out is after plotting a drawing the plottofilepath is now bypassed for some reason. I want the plottofilepath to always be referenced no matter what. 

 

Any ideas?

0 Likes
Message 7 of 16

Moshe-A
Mentor
Mentor

@Kieran.ODonnellP4HWV ,

 

i suggest you first try my lisp before you rule it out. it is base on command reactor (event) which is fired each time you use plot command which sets "plottofilepath" on every drawing.

 

your challenge is to make sure the lisp is loaded on each and opened every drawing.

 

Moshe

 

0 Likes
Message 8 of 16

Moshe-A
Mentor
Mentor

@Kieran.ODonnellP4HWV ,

 

my apology, i was not aware on this, it looks like AutoCAD reads PLOTTOFILEPATH only the first time.

one way to overcome this,  create your own plot command. 

 

Moshe

 

0 Likes
Message 9 of 16

Kieran.ODonnellP4HWV
Participant
Participant

@Moshe-A  this seems to be the best route however I am stuck now. I have the plot working as intended but am unable to figure out how to set the plot location in the command list. 

 

Ideally I want to set the location at some point in the plot command below:

 

^C^C(command "plottofilepath" (getvar "DWGPREFIX"));-plot;y;;DWG To PDF.pc3;ISO full bleed A3 (420.00 x 297.00 MM);m;l;n;l;1:1;0.00,0.00;y;acad.ctb;y;n;n;n;(vl-filename-base (getvar "dwgname"));y;n;y;

 

As you can see I have tried setting the plottofilepath in the command and this works however it still wont print in that location because it isn't part of the plot function. Any ideas?

0 Likes
Message 10 of 16

paullimapa
Mentor
Mentor
Accepted solution

any reason why you don't include a (strcat) function to connect (getvar "DWGPREFIX") with (vl-filename-base (getvar "dwgname")) then you don't need plottofilepath:

^C^C-plot;y;;DWG To PDF.pc3;ISO full bleed A3 (420.00 x 297.00 MM);m;l;n;l;1:1;0.00,0.00;y;acad.ctb;y;n;n;n;(strcat(getvar "DWGPREFIX")(vl-filename-base (getvar "dwgname")));y;n;y;


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

Kieran.ODonnellP4HWV
Participant
Participant
The only reason is incompetence haha I am learning this as I go. This worked thank you so much!
0 Likes
Message 12 of 16

paullimapa
Mentor
Mentor

glad to have helped...cheers!!!


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

Kieran.ODonnellP4HWV
Participant
Participant

Thank you all for your help. Final solution was to create a custom command. 

 

The following macro works perfectly:

 

^C^C-plot;y;;DWG To PDF.pc3;ISO full bleed A3 (420.00 x 297.00 MM);m;l;n;l;1:1;0.00,0.00;y;acad.ctb;y;n;n;n;(strcat(getvar "DWGPREFIX")(vl-filename-base (getvar "dwgname")));y;n;y;

0 Likes
Message 14 of 16

dvrVSNMW
Advocate
Advocate

And how do u use this command? Just type it in command bar? Or do you have to make a LISP of it?

0 Likes
Message 15 of 16

ec-cad
Collaborator
Collaborator

Looks like a 'new' post on this one, so here's a way to use that 'Macro' as a Lisp or add it to your CUI

interface. If it doesn't work for you, repost here for more help.

 

ECCAD

 

 

;^C^C-plot;y;;DWG To PDF.pc3;ISO full bleed A3 (420.00 x 297.00 MM);m;l;n;l;1:1;0.00,0.00;y;acad.ctb;y;n;n;n;(strcat(getvar "DWGPREFIX")(vl-filename-base (getvar "dwgname")));y;n;y;
; Notes:
; Above macro could be used on a ToolBar or in a Menu pick, see help on CUI to add it there.
; IF YOU WANT THE EXACT RESULT IN LISP, make a file with Notepad
; Copy below code into that Notepad file, and save it as filename "PLOTME.lsp"
; You could place the PLOTME.lsp file in any 'Support' folder, then, 
; at the Command Prompt, load it (load "c:/folder/plotme") to run it,
; or add the entire content to a file called acaddoc.lsp, and put that in your \Acad..\support folder
; Once you decide which way to go, you can open Acad and at the Command Prompt line,
; just type in PLOTME
;
; Additional note:
; Your plotter (may) have a different set of questions to answer when you type in (command "-Plot")
; best to write them down in order, and what you input as a response. Tune the C:PLOTME command as
; required.
; ECCAD


(defun C:PLOTME ()
 (command "-plot"
   "y"
   ""
   "DWG To PDF.pc3"
   "ISO full bleed A3 (420.00 x 297.00 MM)"
   "m"
   "1"
   "n"
   "1"
   "1"
   "1"
   "0.00,0.00"
   "y"
   "acad.ctb"
   "Y"
   "n"
   "n"
   "n"
   "(strcat (getvar "DWGPREFIX")(vl-filename-base (getvar "dwgname")))"
   "y"
   "n"
   "y"
  ); end of command
); end of function

 

 

0 Likes
Message 16 of 16

Sea-Haven
Mentor
Mentor

Another notice the PDFname variable so can make final location to where you want, this is cut from Plot range of layouts.

    (COMMAND "-PLOT"  "Y"  "" "Plot 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"
    )

 It uses a window for selection and is matched exactly to an A1 title block but making A3 pdf's. 

0 Likes