Jump to content

script problems


Phil Shanks

Recommended Posts

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.

bctest.jpg

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...