Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

error: Automation Error; Invalid Argument

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
ZSHS2011
2924 Views, 17 Replies

error: Automation Error; Invalid Argument

Hoping you geniuses can figure this out...

 

I have the following line of code that works by itself:

(vla-put-PrinterConfigPath *files* "O:\\AutoCAD Standard Files\\Plotters\\")

 

When I try and change that line of code to add a second path on the local computer:

(vla-put-PrinterConfigPath *files* "O:\\AutoCAD Standard Files\\Plotters;C:\\Plotters")

 

The code comes up with that error message in the title.  (error: Automation Error; Invalid Argument)

Now the HELP file says it can accept multiple paths: (ie. Use a semicolon (;) to separate multiple directories; however, do not end the string with a semicolon.).

 

Why is this not working?  Both path exists and work separately, but when I try combining them, I get that error.  I have tried concatenating them as well in a separate line with no dice.

 

What gives?  I can add the lines manually into the dialog box under options, but not through lisp?

 

Thanks for any help you can offer.

17 REPLIES 17
Message 2 of 18
ZSHS2011
in reply to: ZSHS2011

Anyone have any input?  It would be much easier if I could automate this...

Message 3 of 18
rapidcad
in reply to: ZSHS2011

Hope I can help - I have some similar code running beautifully.

 

 

Here's a piece that sets my printer path

(vla-put-PrinterConfigPath fileprefs   "C:\\CAx\\Resource\\TGW-US\\PLOTTERS")

 

....and here's a piece where I add two more paths to the tool palettes - oldpalettepath is obviously a variable where I have captured the original path

(vla-put-ToolPalettePath fileprefs   (strcat ";C:\\CADUSER\\ToolPalette" ";C:\\CAx\\Resource\\TGDRAW\\ToolPalette" oldpalettepath))

 

these work fine.

 

All I noticed about your code is that you had placed the trailing \\ backslashes in the first line of code,

(vla-put-PrinterConfigPath *files* "O:\\AutoCAD Standard Files\\Plotters\\")

 

but when combining them, you omitted them.

(vla-put-PrinterConfigPath *files* "O:\\AutoCAD Standard Files\\Plotters;C:\\Plotters")

 

I haven't placed them in mine and they work without them. But you had said that that line of code was working alone. Have you tried adding those trailing backslashes? (I'm reaching for answeres here).

 

(vla-put-PrinterConfigPath *files* "O:\\AutoCAD Standard Files\\Plotters\\;C:\\Plotters\\")

 

Or, if "C:\\Plotters" worked, I suppose you wouldn't need the backslashes.

(vla-put-PrinterConfigPath *files* "O:\\AutoCAD Standard Files\\Plotters\\;C:\\Plotters")

 

Otherwise - check and recheck your paths and make sure that you have everything right character for character, and check the permissions on those folders too - maybe that's an issue? Not sure about that though.

 

Your idea should work - although I've never tried running multiple plotter configuration folders before. Another issue could be that both folders might contain the plotter wizzards and having two wizzards mapped side by side very well may cause this error. I have seen errors when I map to a folder containing an older wizzard.

 

HTH

Ron

 

ADN CAD Developer/Operator
Message 4 of 18
ZSHS2011
in reply to: rapidcad

RapidCad,

Thank you for responding. Unfortunately, I have already checked into all that.

For fun, I tried mapping two folders in root "C:". Each works individually, however combining them causes the error.

My test for syntax is to type both into a single line, and then delete half, run it, undo the deletion. Delete the other half, run, undo. Finally, after confirming both halves are correct, run it all together. The only syntax I could be messing up is the joining operator, in this case the semicolon.

If you have a moment, could you try a simple lisp routine to modify your printer locations? I think this is bug, I mean feature, of AutoCAD itself.
Message 5 of 18
bhull1985
in reply to: ZSHS2011

Try placing your paths into variables and using them...

 

(setq path1 "O:\\AutoCAD Standard Files\\Plotters")

(setq path2 "C:\\Plotters")

 

(vla-put-printerConfigPath *files* path1;path2)

 

See if that works?

 

 

If it doesn't you could maybe try it with a list?

(setq pathlist '("O:\\AutoCAD Standard Files\\Plotters" "C:\\Plotters"))

then perhaps

(vla-put-printerConfigPath *files* pathlist)?

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 6 of 18
rapidcad
in reply to: bhull1985

I can't get any of this to work  - not by expressing as variables or by explicitly setting. I even move the wizzard to eliminate that possibility. I can set it for a single path, but not for multiples. BTW, multiple paths were not even a manual add option in 2011. My AutoCAD 2014 activates the "Add" button when you select "Printer Configuration Search Path" in the Options>Files tab, but the same button is greyed out in my AutoCAD 2011. Perhaps the inability to use the vla set method in 2014 is a bug?

ADN CAD Developer/Operator
Message 7 of 18
ZSHS2011
in reply to: bhull1985

Bhull1985,

 

Thank you for replying.  The first suggestion seems to violate LISP syntax, at least as I understand it.  You indicate a free semicolon unbound by quotations which should force the compiler to view the remainder of that line as comment.  Am I mistaken on how AutoCAD views those items?  The built in editor seems to agree with me when I type in that statement. 

 

The second item I have tried already, with no success.  It results in the same error.      

 

 

 

Rapidcad,

 

I am in agreement.  The feature was added in 2012, however it does not appear to be fully functional despite AutoCAD help files indicating it should be possible.  It can be manually set in 2013, however not through LISP.  I cannot speak to 2014.

Message 8 of 18
bhull1985
in reply to: ZSHS2011

Sorry about that, was just spitballing to offer some assistance. Unfortunately it sounds as if i was incorrect. Apologies

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 9 of 18
p_mcknight
in reply to: ZSHS2011

A lot of these types of settings can be handled through environment settings which I find to be a lot easier to manipulate and work with.  Below is some code to add a single directory to the plotter configuration paths.  Modify as necessary and it should work fine for you.

 

(defun c:test22 ( / plotters)
  (setq plotters (getenv "PrinterConfigDir"))
  (setq plotters (strcat plotters ";C:\\logs"))
  (setenv "PrinterConfigDir" plotters)
  (princ)
  )

Message 10 of 18
ZSHS2011
in reply to: p_mcknight

P_McKnight,

 

This is slightly above me, but based on my previous programming I believe this code does the following:

 

(defun c:test22 ( / plotters) ;define function called "C:test22" with argument of plotter. 
  (setq plotters (getenv "PrinterConfigDir"))  ; strait forward set variable to existing config directory
  (setq plotters (strcat plotters ";C:\\logs"))  ; concatenate with new folder path 
  (setenv "PrinterConfigDir" plotters)  ; apply concatenated path to variable
  (princ)  ; Not sure what this does...
  )

 

Why do we need to pass "Plotters" into the function?  Also, what does the backslash character / operator do?  

 

Also, what does "PRINC" do?  I am assuming this prints the result of the function (the concatenated string), but being that function was never assigned a value how does it print that?    

 

Thanks for your help!

Message 11 of 18
ZSHS2011
in reply to: ZSHS2011

Actually, reviewing the code again...

 

I think you have the "plotter" argument to return the result to AutoCAD after completing the function, and the "princ" is just to add a carriage return after the function resolves?

Message 12 of 18
p_mcknight
in reply to: ZSHS2011

Plotters (after the backslash at the top) is declared to run as a local variable (ie it is not stored after it executes).  We then use it to store the current plotter paths to so we don't overwrite them, add our new plotter to the list of paths and rewrite them to the plotter paths.  The initial backslash separates variables we feed to the routine vs local variables.  The last princ function is to 'exit quietly' after the program executes.  Otherwise you get some junk written to your command line.  If you wanted to print the new list of plotters to the command line then add (terpri)(princ plotters) before the final princ.

Message 13 of 18
ZSHS2011
in reply to: p_mcknight

Thanks!  

 

I marked your previously reply as the solution (only needed the "setenv" command) but thank you for learning me some additional LISP today.

 

Is AutoCAD moving away from "VLA-put" method and towards the "setenv"?

Message 14 of 18
p_mcknight
in reply to: ZSHS2011

No, there are plenty of times when vla-put is needed.  But if its a general AutoCAD setting it almost always has an environment variable to go with it.  It is easier to do this than to edit registry keys or to get the AutoCAD objects and whatnot.  The other nifty thing is the ability to set environment variables that don't currently exist.  I do that on a lot of my programs where I want a persistant toggle between AutoCAD sessions for additional program functionality that we have built in.  By running a setenv on a name that currently doesn't exist AutoCAD writes it to the drive and has it there any time in the future if you need it.  Just don't go cluttering up your system with too many junk variables that you don't want to keep.  Glad I could help today.

Message 15 of 18
rapidcad
in reply to: p_mcknight

p_mcknight, Thanks for the education! All I had seen previously was the vlisp when I was researching it last year- now see how the original method works- and it works well!

 

Kudos and thanks! Thanks for sharing the knowledge.

 

Ron

ADN CAD Developer/Operator
Message 16 of 18
dgorsman
in reply to: rapidcad

Using environment variables isn't a replacement for the properties functions (vla-put ...) (vla-get ...) etc.  There can be problems manipulating the environment variables when you have multiple sessions open which share common variables; you can end up with a situation of last-one-out wins, which isn't necessarily what you want.

 

I've looked at handling multiple paths in the plot settings, and can confirm that not handling multiple paths is indeed a bug.  As to whether it will be addressed in future releases, well, that NDA ball gag is going to get in the way.  😄

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 17 of 18
Scottu2
in reply to: p_mcknight

(getenv "PrinterConfigDir")

Thanks P_McKnight! Just what i was looking for. All the other posts refer to the (vla-put-PrinterConfigPath ... ) but it never worked for me, Acad2014.
Message 18 of 18
neiljackson
in reply to: ZSHS2011

This whole task of setting the path settings with (vlax-put-property )
(equivalent to vla-put...) has proven to be (needlessly) more
complicated than it ought to be. The problem is that, at least as far as
I can tell, when you use the (vlax-put-property...) function to
programmatically set the FontFileMap, PrinterConfigPath,
PrinterDescPath, or PrinterStyleSheetPath properties of the
Application.Preferences.PreferencesFiles object, (although the problem
doesn't seem to happen with SupportPath), Autocad looks at the value you
are trying to set these properties to, and applies a needlessly rigorous
test on your proposed new value, raising an exception and not setting
the property if the value fails the test. The test seems to consist of
several checks. Autocad checks to see if you are trying to set these
values to multiple paths with a semicolon-delimited string. If you are,
it fails the test. Autocad also checks to make sure that the path really
exists on the drive. In the case of the printerconfig, I think it also
checks to ensure that the expected files (add-aplotter wizard, and some
.pc3 files probably) are in the folder. This is stupidly restrictive
behavior. Obviously, the intention with this behavior is to prevent a
program from inserting "bad" values into these properties, but this
error-checking verges on being a bug. For one thing, for several of
these settings, the OPTIONS dialog allows the user to set multiple
paths, and yet the programmatic error check fails any new value that has
amultiple paths (semicolon-delimited list). For another thing, it is
certainly legitimate to set the path settings to some paths that do not
exist at the time of the setting; for instance, you might be configuring
Autocad when the computer is not connected to the network that contains
the fileserver that contains the shared folders you want to set as
values of the PrinterConfigPath property.

Autodesk, would you please improve this situation? (or else set me
straight if I am wrong about the validity-testing behavior of the
Application.Preferences.PreferencesFiles object.) Thank you.

 

Sincerely,

Neil Jackson

Autoscan, Inc.

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost