TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: nobody on June 12, 2016, 01:55:10 PM

Title: Script (.SCR) to accept File Name
Post by: nobody on June 12, 2016, 01:55:10 PM
Anyone know how to pass the filename to the command line from a script file for "-exporttoautocad"? I don't want to overwrite the original.

Thanks!
Title: Re: Script (.SCR) to accept File Name
Post by: roy_043 on June 12, 2016, 03:24:19 PM
Do you mean this?:
Code: [Select]
(strcat (getvar 'dwgprefix) (getvar 'dwgname) "MySuffix")
Title: Re: Script (.SCR) to accept File Name
Post by: nobody on June 12, 2016, 04:54:52 PM
Thanks Roy. That works for autolisp but what I need is something that will work with a "script" file
Title: Re: Script (.SCR) to accept File Name
Post by: roy_043 on June 13, 2016, 04:11:26 AM
You should also be able to use Lisp code in a .scr file. But, depending on the context, you may have to change the TEXTEVAL variable. Using a (command "_.-exporttoautocad ...) structure inside the script may also work.
Title: Re: Script (.SCR) to accept File Name
Post by: nobody on June 13, 2016, 07:58:43 AM
Thanks Roy, what I ended up doing is add a suffix through -exporttoautocad command line settings...worked well enough.
Title: Re: Script (.SCR) to accept File Name
Post by: ChrisCarlson on June 13, 2016, 10:07:57 AM
I would incorporate a basic lisp routine to check if your output file exists. If memory serves me right, if it exists the default prompts will not overwrite the .dwg with the new export as it will prefix the output with "ACAD-".

Perhaps, something like this before your export line.

Code - Auto/Visual Lisp: [Select]
  1. (if
  2.         (setq outputfile
  3.                 (findfile (strcat (getvar "dwgprefix") outputname))
  4.         ) ; setq
  5.         (vl-file-delete outputfile) ; delete if found
  6.         (princ) ; do nothing if not found
  7. ) ; end if             
  8.