Phil Shanks Posted January 26, 2016 Share Posted January 26, 2016 I am new to script writing and am trying to make one that will replace the title block in a couple hundred files. I have all files and dwgs in a folder named bctest on my c: drive(c:\bctest). I'll make an example list below. a.102.0.01.dwg a.103.1.07.dwg a.104.1.01.dwg etc....... kbi P&idTblk.dwg bctest_update.bat bctest_update.lsp bctest_update.scr script file INSERT "kbi P&IDTblk"=c:\bctest\A* Y ^C^C 0,0 1 1 0 ERASE L (load "c:\\bctest\\bctest_update.lsp") bctest_update QUIT Y lisp file (defun c:bctest_update(/ dn pa panbdn) (setq dn (getvar "dwgname")) (setq pa (getvar "dwgprefix")) (setq panbdn (strcat pa "new\\" dn)) (command "save" panbdn ) ) batch file md c:\bctest\new for %%f in (c:\bctest\A*.dwg) do START/WAIT c:\"program files"\"autodesk"\"Autocad 2015"\acad.exe "%%f"/b c:\bctest\bctest_update.scr When i initiate the bat file it creates a folder named new, opens up acad, then cannot find any of the files. I've attached a snapshot of the errors that come up. I am new to all of this. So any help would be great thanks for your help. Quote Link to comment Share on other sites More sharing options...
YZ Posted February 2, 2016 Share Posted February 2, 2016 Hey there, welcome to the forum. Normally you get faster responses than this, though the scripts part of the forum can be a forgotten corner sometimes. I applaud your efforst to automate this! Can we strip a few parts out of this process to troubleshoot? First, does the script work if you run it manually on an open dwg? Next, can you run the batch file in a test area where you don't create another foler called "New"? Just input and output from the same folder, fo rtesting. See what comes of that, and hopefully we can narrow down where the error could be. Quote Link to comment Share on other sites More sharing options...
Phil Shanks Posted February 2, 2016 Author Share Posted February 2, 2016 Script does not work manually. do i just delete this part of the batch? md c:\bctest\new and then run it? Thanks YZ Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 3, 2016 Share Posted February 3, 2016 I would write the script in a form that can be read simply then carry out the changes via a lisp, you add your code to say acaddoc.lsp this way it autoloads and is available for every dwg 2nd example loads lisp each time, I think your over complicating what you are trying to do. What about delete existing title block ? Your script part has a number of errors open dwg1 (bctest_update) close n open dwg2 (bctest_update) close n Ok now some help from Windows go to the START lower left type CMD you will open a command window. cd \bctest dir *.dwg >dirlst /b you now have a list of every dwg in your bctest directory as a text file Open dirlst with word using search/replace replace ^p with ^popen you now have open dwg1 open dwg2 replace ^p with (load "bctest") close n^p you now have open dwg1 (load "bctest") close n open dwg2 (load "bctest") close n save as a text file bctest.scr Quote Link to comment Share on other sites More sharing options...
YZ Posted February 4, 2016 Share Posted February 4, 2016 Script does not work manually. do i just delete this part of the batch? md c:\bctest\new and then run it? Thanks YZ To test the script in AutoCAD type "Script" in command line, and browse to the script file, and click "Open". If the script does not do what you want it to do on one of your drawings, then that is the first place to troubleshoot. Work on the batch file later. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.