TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: dubb on August 26, 2015, 05:29:14 PM

Title: printerconfigpath automation error
Post by: dubb on August 26, 2015, 05:29:14 PM
Code: [Select]
(vl-load-com)
(setq PreferenceFiles (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
;print/plotter settings
(setq AddPrintPath (strcat "n:\\cad_support\\plotter"))
(setq CurrentPrintPath (strcat (vla-get-PrinterConfigPath PreferenceFiles)))
(setq NewPrintPath (strcat AddPrintPath";"CurrentPrintPath))
(vla-put-printerconfigpath PreferenceFiles NewPrintPath)

I get an error
Quote
Automation Error. Invalid Argument

What am I doing wrong? :nerdyembarassed:
Title: Re: printerconfigpath automation error
Post by: Lee Mac on August 26, 2015, 05:47:01 PM
I don't see anything wrong with your code - perhaps there is a bug with the ActiveX printerconfigpath property.

Try the following alternative method, changing the registry value directly:
Code - Auto/Visual Lisp: [Select]
  1. (setq new "n:\\cad_support\\plotter"
  2.       cur (getenv "PrinterConfigDir")
  3. )
  4.     (setenv "PrinterConfigDir" (strcat new ";" cur))
  5. )
Title: Re: printerconfigpath automation error
Post by: dubb on August 26, 2015, 05:56:58 PM
This works Thanks Lee.

I don't see anything wrong with your code - perhaps there is a bug with the ActiveX printerconfigpath property.

Try the following alternative method, changing the registry value directly:
Code - Auto/Visual Lisp: [Select]
  1. (setq new "n:\\cad_support\\plotter"
  2.       cur (getenv "PrinterConfigDir")
  3. )
  4.     (setenv "PrinterConfigDir" (strcat new ";" cur))
  5. )
Title: Re: printerconfigpath automation error
Post by: ChrisCarlson on August 27, 2015, 08:26:47 AM
I'm not sure what you are even trying to do ? All you really need to do is

Code - Auto/Visual Lisp: [Select]


Not sure why you are pulling the old config path?
Title: Re: printerconfigpath automation error
Post by: Lee Mac on August 27, 2015, 08:44:28 AM
Not sure why you are pulling the old config path?

The OP is adding a new path to the existing set of paths.
Title: Re: printerconfigpath automation error
Post by: ChrisCarlson on August 27, 2015, 10:27:59 AM
His snippet seems to works on Vanilla 2016. He just needs to add a check to prevent duplicate line items.

Is there an advantage to writing to the registry directly vs ActiveX?