Author Topic: Script (.SCR) to accept File Name  (Read 1561 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Script (.SCR) to accept File Name
« 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!

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Script (.SCR) to accept File Name
« Reply #1 on: June 12, 2016, 03:24:19 PM »
Do you mean this?:
Code: [Select]
(strcat (getvar 'dwgprefix) (getvar 'dwgname) "MySuffix")

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Script (.SCR) to accept File Name
« Reply #2 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

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Script (.SCR) to accept File Name
« Reply #3 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.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Script (.SCR) to accept File Name
« Reply #4 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.

ChrisCarlson

  • Guest
Re: Script (.SCR) to accept File Name
« Reply #5 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.